mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-08-03 10:28:41 +00:00
API level fix
Added 'has' test for Activity.getProfileInfo(). Reverted automatic changes to XML prettiness. Co-Authored-By: Joseph Abbey <me@josephabbey.dev>
This commit is contained in:
@ -75,27 +75,30 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
||||
},
|
||||
method(:onReturnBatteryUpdate)
|
||||
);
|
||||
var data = [
|
||||
{
|
||||
"state" => System.getSystemStats().battery,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "battery_level"
|
||||
},
|
||||
{
|
||||
"state" => System.getSystemStats().charging,
|
||||
"type" => "binary_sensor",
|
||||
"unique_id" => "battery_is_charging"
|
||||
}
|
||||
];
|
||||
if (Activity has :getProfileInfo) {
|
||||
data.add({
|
||||
"state" => Activity.getProfileInfo().name,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "activity"
|
||||
});
|
||||
}
|
||||
Communications.makeWebRequest(
|
||||
(Properties.getValue("api_url") as Lang.String) + "/webhook/" + (Properties.getValue("webhook_id") as Lang.String),
|
||||
{
|
||||
"type" => "update_sensor_states",
|
||||
"data" => [
|
||||
{
|
||||
"state" => System.getSystemStats().battery,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "battery_level"
|
||||
},
|
||||
{
|
||||
"state" => System.getSystemStats().charging,
|
||||
"type" => "binary_sensor",
|
||||
"unique_id" => "battery_is_charging"
|
||||
},
|
||||
{
|
||||
"state" => Activity.getProfileInfo().name,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "activity"
|
||||
}
|
||||
]
|
||||
"data" => data
|
||||
},
|
||||
{
|
||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||
|
@ -182,14 +182,16 @@ class WebhookManager {
|
||||
break;
|
||||
case 1:
|
||||
// System.println("WebhookManager onReturnRegisterWebhookSensor(): Registering next sensor: Activity");
|
||||
registerWebhookSensor({
|
||||
"name" => "Activity",
|
||||
"state" => Activity.getProfileInfo().name,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "activity",
|
||||
"disabled" => false
|
||||
}, 2);
|
||||
break;
|
||||
if (Activity has :getProfileInfo) {
|
||||
registerWebhookSensor({
|
||||
"name" => "Activity",
|
||||
"state" => Activity.getProfileInfo().name,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "activity",
|
||||
"disabled" => false
|
||||
}, 2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user