Responses in my feature request thread indicate that HA already has the necessary pieces to create (and update) odometers for my e-bikes. There isn’t currently a HA integration for our bikes, so I created odometer entities manually using custom variables in my config, i.e.:
var:
bike_odometer_hsd:
friendly_name: "Tern HSD Bike Odometer"
unique_id: bike_odometer_hsd
unit_of_measurement: mi
icon: mdi:counter
restore: true
bike_odometer_nbd:
friendly_name: "Tern NBD Bike Odometer"
unique_id: bike_odometer_nbd
unit_of_measurement: mi
icon: mdi:counter
restore: true
I’ve been using a Siri Shortcut on my phone that calls var.update
to manually update them every week or two. These vars don’t retain long-term data though, so I’d love to replace them with proper sensor
entities as described in the responses to my other thread.
I read the long-term stats documentation, did many troubleshooting attempts using logged errors as guidance, and am to the point where I need help. I have yet to see my new entities to appear in the entities list. My config includes:
template:
template odometers: !include templates/sensors/odometers.yaml
…and templates/sensors/odometers.yaml contains:
- sensors:
- name: "bike_odometer_hsd"
device_class: distance
# state_class: total_increasing
state_class: measurement
unit_of_measurement: mi
state: "{{ states('var.bike_odometer_hsd') | int }}"
- name: "bike_odometer_nbd"
device_class: distance
# state_class: total_increasing
state_class: measurement
unit_of_measurement: mi
state: "{{ states('var.bike_odometer_nbd') | int }}"
I wasn’t sure what to put as the state for these, since there’s no actual device or integration to set/update their values. Figured I could continue using the custom variables entities I created previously until there’s a proper integration. Where am I going wrong in the config, and what mechanism should I use to update the odometer values for each bike?