Quite new to home assistant but truth to be told it’s a very hard learning curve with anything which cannot be done in the UI.
Use case:
- HA installed in a campervan and I have a tracker device which hasn’t got a unique ID and the latitude, longitude coordinates and the altitude are only available as attributes. I need to convert these attributes to sensors to use them in HA.
device_tracker:
- platform: traccar
host: localhost
port: 18682
username: myusername
password: mypassword
event: ['device_moving', 'device_stopped']
new_device_defaults:
track_new_devices: true
- I would like to update the Home (zone.home) location (ie the lat/lon/alt) in every 5 minutes based on said tracker device location after a trigger event (when above tracker left zone.home)
Achivements:
- none - see later
- I setup three number helpers input_number.home_latitude, input_number.home_longitude and input_number.home_altitude
Then I managed to set up an automation which updates zone.home by calling the homeassistant.set_location service based on the coordinates I manually feed in to the helpers.
That was two days ago.
Now it’s 7am, soon I’d need to get up but still here I am and this was my best shot at it (obviously rewritten and changed a 100 times)
sensor:
- platform: template
sensors:
van_latitude:
value_template:
"{% set input_number.home_latitude = state_attr('device_tracker.crafter', 'latitude') | float %}"
van_longitude:
value_template:
"{% set input_number.home_longitude = state_attr('device_tracker.crafter', 'longitude') | float %}"
van_altitude:
value_template:
"{% set input_number.home_altitude = state_attr('device_tracker.crafter', 'altitude') | float %}"
This latest version does not work (just like any previous ones) and also gives me a config error.
Please!
Edit: Obviously, I am open to suggestions as I have a feeling, that there must be a more streamlined and elegant solution…