mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-20 21:38:35 +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:
@ -25,8 +25,7 @@
|
|||||||
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
||||||
to update the application attributes.
|
to update the application attributes.
|
||||||
-->
|
-->
|
||||||
<iq:application id="4901cdfb-b4a2-4f33-96c7-f5be5992809e" type="widget" name="@Strings.AppName"
|
<iq:application id="4901cdfb-b4a2-4f33-96c7-f5be5992809e" type="widget" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||||
entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
|
||||||
<!--
|
<!--
|
||||||
Use the following from the Visual Studio Code comand palette to edit
|
Use the following from the Visual Studio Code comand palette to edit
|
||||||
the build targets:
|
the build targets:
|
||||||
|
@ -28,11 +28,9 @@
|
|||||||
Testing in VSCode requires monkey.jungle, so for convenience, swap between
|
Testing in VSCode requires monkey.jungle, so for convenience, swap between
|
||||||
watch-app and widget by changing which of the next two lines are commented out
|
watch-app and widget by changing which of the next two lines are commented out
|
||||||
-->
|
-->
|
||||||
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app" name="@Strings.AppName"
|
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||||
entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
|
||||||
<!--
|
<!--
|
||||||
<iq:application id="4901cdfb-b4a2-4f33-96c7-f5be5992809e" type="widget" name="@Strings.AppName"
|
<iq:application id="4901cdfb-b4a2-4f33-96c7-f5be5992809e" type="widget" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||||
entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
|
||||||
-->
|
-->
|
||||||
<!--
|
<!--
|
||||||
Use the following from the Visual Studio Code comand palette to edit
|
Use the following from the Visual Studio Code comand palette to edit
|
||||||
|
@ -75,11 +75,7 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
|||||||
},
|
},
|
||||||
method(:onReturnBatteryUpdate)
|
method(:onReturnBatteryUpdate)
|
||||||
);
|
);
|
||||||
Communications.makeWebRequest(
|
var data = [
|
||||||
(Properties.getValue("api_url") as Lang.String) + "/webhook/" + (Properties.getValue("webhook_id") as Lang.String),
|
|
||||||
{
|
|
||||||
"type" => "update_sensor_states",
|
|
||||||
"data" => [
|
|
||||||
{
|
{
|
||||||
"state" => System.getSystemStats().battery,
|
"state" => System.getSystemStats().battery,
|
||||||
"type" => "sensor",
|
"type" => "sensor",
|
||||||
@ -89,13 +85,20 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
|||||||
"state" => System.getSystemStats().charging,
|
"state" => System.getSystemStats().charging,
|
||||||
"type" => "binary_sensor",
|
"type" => "binary_sensor",
|
||||||
"unique_id" => "battery_is_charging"
|
"unique_id" => "battery_is_charging"
|
||||||
},
|
}
|
||||||
{
|
];
|
||||||
|
if (Activity has :getProfileInfo) {
|
||||||
|
data.add({
|
||||||
"state" => Activity.getProfileInfo().name,
|
"state" => Activity.getProfileInfo().name,
|
||||||
"type" => "sensor",
|
"type" => "sensor",
|
||||||
"unique_id" => "activity"
|
"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" => data
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||||
|
@ -182,6 +182,7 @@ class WebhookManager {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// System.println("WebhookManager onReturnRegisterWebhookSensor(): Registering next sensor: Activity");
|
// System.println("WebhookManager onReturnRegisterWebhookSensor(): Registering next sensor: Activity");
|
||||||
|
if (Activity has :getProfileInfo) {
|
||||||
registerWebhookSensor({
|
registerWebhookSensor({
|
||||||
"name" => "Activity",
|
"name" => "Activity",
|
||||||
"state" => Activity.getProfileInfo().name,
|
"state" => Activity.getProfileInfo().name,
|
||||||
@ -190,6 +191,7 @@ class WebhookManager {
|
|||||||
"disabled" => false
|
"disabled" => false
|
||||||
}, 2);
|
}, 2);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user