Homeassistant seems to convert it somehow automatically. And it does work for the other automation and I donât think this is the problem. I assume the problem is, that the object is missing as the binary sensor is not at all part of this automation.
Ah ok.
I create my automations in YAML so my mistake - thatâll teach me not to try and provide a quick response whilst coding elsewhere. Apologies for the confusion.
You need to use the binary_sensor state (which will persist through restarts) to set the initial device_tracker state on startup.
You can use trigger.to_state.state with the other automation replicating changes from binary_sensor to device_tracker.
I got your point and I guess I am not able to explain myself probably, so I will try again.
In order to replace the device with the sensor data I need to read the sensor data.
Which for the automation that is constantly checking I do with example.
For my second automation the trigger is not the binary sensor but the homeassistant restart. Therefore no value. I tried to replace
trigger.to_state.state with state.binary_sensor.gigaset_red or binary_sensor.gigaset_red.state
Will take your advice of sharing code for next time.
Thanks for your help now everything works fine.
For documentation purpose I am putting everything here in one place.
alias: Presence Giga Red
description: ''
trigger:
- platform: state
entity_id: binary_sensor.gigaset_red
condition: []
action:
- service: device_tracker.see
data:
dev_id: gigagregor
location_name: |
{% if trigger.to_state.state == 'on' %}
home
{% elif trigger.to_state.state == 'off' %}
not_home
{% else %}
unknown
{% endif %}
source_type: router
mode: single
max: 10