Closed philipabbey closed 6 months ago
Looking trivial to extract from the watch:
var myLocation = Position.getInfo().position.toDegrees();
System.println("Position, lat: " + myLocation[0] + " long: " + myLocation[1]);
@JosephAbbey What's the best way to include this in the API call?
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"
}
]
},
{
:method => Communications.HTTP_REQUEST_METHOD_POST,
:headers => {
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON
},
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
},
method(:onReturnBatteryUpdate)
);
I can then test on a real device.
You would also need to amend the WebhookManager
setup to include it as a sensor.
Although, the official way is to use a separate request, as seen here, this creates an actual device tracker in homeassistant, rather than a sensor.
I currently have a version that includes the current activity type on my local branch which uses the original request.
User request from https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348/150
So the background service would report both battery level, charging state and now GPS too. There could be a dependency on the granularity of the GPS since workout Apps usually take a while to pick up satelites and refine the GPS to a few meters, and the battery is in greater demand at these higher accuracies.