I created an automation that was working just fine and since I added a condition to it that includes a sensor with a templated state, it has stopped working.
My automation triggers when my garage door opens at night and the house is dark. It simply turns on all my lights so I don’t stumble into a pitch black house. It worked fine when the only conditions I had was a light sensor was below a specific value and the sun was below the horizon. Everything worked as expected. However, I ran into some situations where I would leave early, before sunrise, which would leave the lights on all day, or I would come in really late from a trip and when I got home, all the lights would come on waking my kids up. The solution I came up with was to use the device tracking and if someone was home, do not trigger the automation.
So, I browsed around and found an example that monitors multiple device trackers and updates a sensor.
- platform: template
sensors:
someone_home:
friendly_name: Someone Home
icon_template: >-
{% if is_state('binary_sensor.someone_home','on') %}
mdi:home-account
{% else %}
mdi:home-outline
{% endif %}
value_template: "{{ is_state('person.chad','home') or is_state('person.tiffany','home') }}"
The sensor works just fine. It returns a ‘True’ or ‘False’ if someone is home.
Here’s my automation with the new sensor included as a condition:
- id: '1559016728404'
alias: Nighttime Dark House
trigger:
- entity_id: binary_sensor.ecolink_door_window_sensor_sensor
from: 'off'
platform: state
to: 'on'
condition:
- below: '5'
condition: numeric_state
entity_id: sensor.vision_security_zp3111_multisensor_4in1_luminance
- condition: state
entity_id: sun.sun
state: below_horizon
- condition: state
entity_id: sensor.someone_home
state: 'False'
action:
- data:
entity_id: group.home_all_lights
service: homeassistant.turn_on
I don’t see anything glaringly obvious so the only thing I can think is that I’m using the wrong value for my new sensor. Instead of True and False, should it be ‘off’ or ‘on’ on maybe even 1 or 0? If I remove the sensor condition, it goes back to working correctly.
Can anyone see where my mistake is?