I have an automation that saves the sensor values to a file.
I have 5 Xiaomi aqara temperature sensors.
For 2 of the sensors I can save temperature and battery level without any problems.
But for the remaining 3 sensors the automation will stop working if I add the battery level Entity ID.
I will give an example.
This work:
Sensor 1:
Temperature Entity ID: sensor.aqara_1_3
Battery Level Entity ID: sensor.aqara_1_battery_level
Iām using the following code in my automation.
{{ states.sensor.aqara_1_3.state }};{{ states.sensor.aqara_1_battery_level.state }}
This will stop the automation script from working:
Sensor 3:
Temperature Entity ID: sensor.temperature_8
Battery Level Entity ID: sensor.3_kok_battery_level
In this case Iām using:
{{ states.sensor.temperature_8.state }};{{ states.sensor.3_kok_battery_level.state }}
If I remove the last part: ;{{ states.sensor.3_kok_battery_level.state }} the automation works.
In Lovelace UI itās no problem to add the battery level for Sensor 3 (sensor.3_kok_battery_level) but if I use it in an automation like above it wonāt work.
Can someone explain why I have this problem and how to solve it?
I might be stupid or dumbā¦
I tried to change to: {{ states.sensor.['3_kok_battery_level'].state }}
as described(?) in the tip from @VDRainer, but it still failsā¦