Robufz
June 19, 2023, 11:37pm
1
I want to do this:
homeassistant:
latitude: "{{ states('sensor.DecLatitude') }}"
longitude: "{{ states('sensor.DecLongitude') }}"
But it will not parse. Is it not possible to set the homeassistant attributes like this? Do they need to be static?
Most configuration variables do not accept templating. Those that do are marked in their integration’s Configuration Variables section with “template” as the acceptable data type instead of “string”, “integer”, “float”, etc.
It looks like it works if zone are set in configuration.yaml and then changed by python script…
I made a zone in configuration.yaml like this:
zone:
- name: home
latitude: 55.986105
longitude: 12.496975
radius: 7
icon: mdi:home
- name: autocamper
latitude: 55.986105
longitude: 12.496975
radius: 15
icon: mdi:rv-truck
And used Python Entities Script from HACS and made an automation like tis
service: python_script.hass_entities
data:
action: set_attributes…
https://community.home-assistant.io/search?q=RV%20zone
Robufz
June 19, 2023, 11:52pm
3
I think I just figured it out. Put the code into an automation…
trigger:
- platform: time_pattern
minutes: /10
condition: []
action:
- service: homeassistant.set_location
data_template:
latitude: |
{{ states('sensor.DecLatitude') }}
longitude: |
{{ states('sensor.DecLongitude') }}
mode: single
Well that’s a service I never noticed before…
Entity IDs need to be slugs… switch the upper case letters to lower case and it should be good.
Robufz
June 22, 2023, 1:26pm
5
It actually works.
I have seen this slugs advice before and I am slowly getting into the habit. But actually all my code works with uppercase names. Must be some situations where it is bad.