I want to use a rest service where I need parameters like time zone, date and coordinates (latitude & longitude). Everythings works fine with date and time zone. The resource_template I use then is like:
But as soon as I want to replace the latitude or longitude from coords from hardcoded to something like state_attr('zone.home', 'latitude'), the rest call will fail. I tried different syntaxes, like:
I also tried in the template editor and also works for me with different syntax’s. De yyyy-mm-dd and tz works fine, but only zone.home works in the template editor but not in the rest sensor!
I added value_template, Latitude (value_template: "{{ state_attr('zone.home', 'latitude') | round(2) | string }}") en Longitude as extra entities to check and these show the correct values. But the entities retrieved from the json are Unknown now. As soon as I enter the latitude and longitude hardcoded in the resource_template, it works fine.
Whauw. Great job. Thnx!!! Didn’t realize that this is the solution? So a restart is not enough in this case? Because with other implementations, like my PWS, I didn’t have these problems!
Out of interest - has anyone tried waiting until Home Assistant has fully started, and then issued a homeassistant.update_entity command using the sensor as the entity_id to update? It’s very possible that when the REST call is made after Home Assistant has loaded the integration, that the Zone integration has not loaded yet?
Might indeed be caused by the zone → rest → template sensor not being available after restart. Honestly I don’t know in what exact order the integrations are loaded.
Don’t think it matters much, because each integration will take a different amount of time to load anyway. But if it is fixed with the homeassistant.update_entity command, then it can be easily sorted with an automation that uses homeassistant start as the trigger, and then issues the update entity command for that sensor.
It is strange then that the Zone initialization does take that much amount of time. I want to integrate other services which are using lat and lon from HA, and I don’t have any experience with the HA automations. I just migrated from Domoticz to HA, and in Domoticz it was very easy to create automations with eg. Blockly. Can you give me a hint how to set up this automation in HA?