Home | Switches | Actions | Templates | Battery Reporting | Trouble Shooting | Version History
The background service can report the following statuses from your device to your Home Assistant:
- Battery Level with charging status.
- Location and location accuracy.
- Activity information, but only if your device supports API level 3.2.0. If your device does not support this API level, this information is simply omitted. How do you know? Easiest way is to see if the data is reported.
If your device does not support the background service, the application will clear this setting after you have enabled it. This tells you that you are unable to take advantage of the background reporting service for the functions below.
The values are merely samples of your device's current status. They are sent by a single background service at the repetition frequency you chose in the settings. The samples are sent at that one rate only, they do not vary for example on in activity, on charge, time of day. You get one refresh interval and that is it. If you want to change the refresh interval, you change your settings. We do appreciate that may not be what you would ideally like to trigger actions on Home Assistant. Messing with the repeat interval of the background service requires more code, more settings and more complexity. That means older devices using widgets would have to be taken out of support to achieve it.
Please do not ask for these to be made 'events'. Garmin's Connect IQ background service is limited in that while it does provide an onActivityCompleted()
method, it does not provide an onActivityStarted()
method, so you would not have the complete activity life cycle anyway. So we're keeping this implementation simple, you just get a sampling at one refresh rate. This probably limits you to updating a status on a Home Assistant Dashboard only.
From version 2.1 the application includes a background service to report the current device battery level and charging status back to Home Assistant. This is a feature that Garmin omitted to include with the Bluetooth connection.
From version 2.6 the application includes reporting your location. The location data reported includes:
- Location (latitude and longitude)
- Location accuracy
- Speed
- Direction
- Altitude
You get whatever your device provides at the moment, i.e. at the accuracy the device currently provides. If your watch is not calibrated you get poor data. It might mean that you get more accurate location data when you are in a location tracking activity (i.e. not swimming pool lengths). The device indicates an accuracy in units of:
Position.QUALITY_NOT_AVAILABLE
- No update providedPosition.QUALITY_LAST_KNOWN
- No update providedPosition.QUALITY_POOR
- We translate that to 500 m arbitrarilyPosition.QUALITY_USABLE
- We translate that to 100 m arbitrarilyPosition.QUALITY_GOOD
- We translate that to 10 m arbitrarily
You cannot rely on the radius of the circle of accuracy in any resulting maps as any meaningful indication of error.
From version 2.6 the application includes reporting your activity. The activity data includes:
- Activity - This is an integer as defined by Toybox.Activity
SPORT
- Sub-activity - This is an integer as defined by Toybox.Activity
SUB_SPORT
The application only provides the integers without translation. When using the values in Home Assistant, you will need to provide you own mapping from the Activity
enumerated type to the human readable text. As developers of the application we are pushing this translation to the server to keep the Garmin application code 'lean'. You will also need to add to both the list of activities (sports) and sub-activities (sub-sports) an interpretation of integer -1
for no activity/sub-activity at present.
The main drawback of this solution is that the Garmin application must be run once with the feature enabled in the settings before reporting will start. Reporting continues after you have exited the application. This is a limit we cannot code around.
It should be as simple as starting the application (or widget). There should be a new device in the mobile app integration called Garmin Watch
with the battery level and charging status.
If this is not the case, head over to the troubleshooting page.
To stop the reporting, the option must be turned off in the settings and then the application run once. Running the application then removes the background service. Both the enable and repeat time settings can be changed whilst the application is running (i.e. live) and the background service will be amended.
When the device is first created, it will be called Garmin Watch
. This can be changed in the mobile app integration settings (button below).
Select the device called Garmin Watch
and then click on the edit icon in the top right corner. You can then change the name of the device to whatever you like, then press UPDATE
and then RENAME
.
In configuration.yaml
:
template:
- sensor:
- name: "<device-name> Battery Level"
unique_id: "<unique-id>"
device_class: "battery"
unit_of_measurement: "%"
state_class: "measurement"
state: "{{ states('sensor.<device>_battery_level') }}"
icon: "mdi:battery{% if is_state('binary_sensor.<device>_battery_is_charging', 'on') %}-charging{% endif %}{% if 0 < (states('sensor.<device>_battery_level') | float / 10 ) | round(0) * 10 < 100 %}-{{ (states('sensor.<device>_battery_level') | float / 10 ) | round(0) * 10 }}{% else %}{% if (states('sensor.<device>_battery_level') | float / 10 ) | round(0) * 10 == 0 %}-outline{% else %}{% if is_state('binary_sensor.<device>_battery_is_charging', 'on') %}-100{% endif %}{% endif %}{% endif %}"
A gauge for battery level with a charging icon making use of mushroom cards, card_mod and stack-in-card:
In lovelace:
type: custom:stack-in-card
direction: vertical
cards:
- type: custom:mushroom-chips-card
card_mod:
style: |
ha-card {
height: 0.25rem;
}
chips:
- type: conditional
conditions:
- condition: state
entity: binary_sensor.<device>_battery_is_charging
state: "on"
chip:
type: entity
icon_color: yellow
entity: sensor.<device>_battery_level
content_info: none
use_entity_picture: false
card_mod:
style: |
ha-card {
border: none !important;
}
- type: conditional
conditions:
- condition: state
entity: binary_sensor.<device>_battery_is_charging
state: "off"
chip:
type: entity
entity: sensor.<device>_battery_level
content_info: none
use_entity_picture: false
card_mod:
style: |
ha-card {
border: none !important;
}
- type: gauge
entity: sensor.<device>_battery_level
unit: "%"
name: Watch
needle: false
severity:
green: 50
yellow: 20
red: 0
card_mod:
style: |
ha-card {
border: none !important;
}
N.B. sensor.<device>_battery_level
will likely need to be changed to sensor.<device>_battery_level_2
if you have fixed the icon as above.
You should remove your old template sensors before migrating to the new integration. You can do this by removing the sensor.<device>_battery_level
and binary_sensor.<device>_battery_is_charging
entities from configuration.yaml
and then restarting Home Assistant or reloading the YAML.
Here is the old configuration method for reference.
While all of the entries have the same name, you can identify which to delete by clicking through to its device which should have a changed name from when it was set up.