Hi,
I am trying to use one automation to turn off lights and devices when i am not home. I have made up the following code, but it does not seems to work. I will receive the push notification with the devices which were on correctly, but the device is never turned off.
- id: Notify device or lamp still on when leaving
alias: 'Notify device or lamp still on when leaving'
initial_state: 'on'
trigger:
- platform: state
entity_id: group.all_devices
to: 'not_home'
for:
minutes: 10
condition:
condition: or
conditions:
- condition: state
entity_id: switch.plug_158d00019d43e8
state: 'on'
- condition: state
entity_id: light.level #huiskamer_tafel
state: 'on'
- condition: state
entity_id: light.level_2 #huiskamer_plafond
state: 'on'
- condition: state
entity_id: switch.plug_158d0001a6592f
state: 'on'
- condition: state
entity_id: switch.plug_158d0001dae65a
state: 'on'
- condition: state
entity_id: light.kast
state: 'on'
- condition: state
entity_id: media_player.tv
state: 'on'
- condition: state
entity_id: media_player.denon_receiver
state: 'on'
- condition: template
value_template: "{{ states.media_player.ziggo_mediabox.state != 'off' }}"
action:
- service: notify.iphone
data_template:
title: Automatische actie ivm afwezigheid
message: >
{% if states.switch.plug_158d00019d43e8.state == 'on' %}
De huiskamer hoeklamp stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.light.level.state == 'on' %}
De huiskamer tafellamp stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.light.level_2.state == 'on' %}
De huiskamer plafondlamp stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.switch.plug_158d0001a6592f.state == 'on' %}
De keukenlamp stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.switch.plug_158d0001dae65a.state == 'on' %}
De tuinverliching stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.light.kast.state == 'on' %}
De kastverlichting stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.media_player.tv.state == 'on' %}
De TV stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.media_player.denon_receiver.state == 'on' %}
De Receiver stond nog aan. Deze is uitgezet.
{%endif%}
{% if states.media_player.ziggo_mediabox.state != 'off' %}
De Ziggobox stond nog aan. Deze is uitgezet.
{%endif%}
- service: homeassistant.turn_off
data_template:
entity_id: >
{% if states.switch.plug_158d00019d43e8.state == 'on' %}
switch.plug_158d00019d43e8
{%endif%}
{% if states.light.level.state == 'on' %}
light.level
{%endif%}
{% if states.light.level_2.state == 'on' %}
light.level_2
{%endif%}
{% if states.switch.plug_158d0001a6592f.state == 'on' %}
switch.plug_158d0001a6592f
{%endif%}
{% if states.switch.plug_158d0001dae65a.state == 'on' %}
switch.plug_158d0001dae65a
{%endif%}
{% if states.light.kast.state == 'on' %}
light.kast
{%endif%}
{% if states.media_player.tv.state == 'on' %}
media_player.tv
{%endif%}
{% if states.media_player.denon_receiver.state == 'on' %}
media_player.denon_receiver
{%endif%}
{% if states.media_player.ziggo_mediabox.state != 'off' %}
media_player.ziggo_mediabox
{%endif%}
somebody an idea?
thanks