sebdoan
(Sebastian Doan)
September 2, 2019, 1:13am
1
Hey Everyone,
Can anyone see what’s wrong with my Automation Configuration below. It works… but only ONCE.
This templating works fine for me with STATE values, but i have this prorblem using ATTRIBUTE values. After the first event, i either have to reload automations or reboot Home Assistant for the trigger to work again.
Any ideas?
automation:
- alias: NOTIFICATION Ecobee Mode Changes
trigger:
- platform: template
value_template: >
{% if is_state_attr('climate.home', 'preset_mode', 'Away') %}
true
{% elif is_state_attr('climate.home', 'preset_mode', 'Home') %}
true
{% elif is_state_attr('climate.home', 'preset_mode', 'Transition') %}
true
{% elif is_state_attr('climate.home', 'preset_mode', 'Sleep') %}
true
{% endif %}
action:
- service: notify.slack
data:
title: 'Heater Mode Changed'
message: 'Ecobee Heater set to {{ state_attr("climate.home","preset_mode") }}, {{now().strftime("%A %H:%M:%S %d-%m-%Y")}}'
sebdoan
(Sebastian Doan)
September 2, 2019, 1:46am
2
If anyone knows why Atrribute value changes with Template Triggers don’t work, please advise. I can’t see anything wrong with the code???
For now I’ve just created a template sensor to capture the attribute value and have made an automation from that. Like below.
sensor:
- platform: template
ecobeemode:
value_template: '{{states.climate.home.attributes.preset_mode }}'
friendly_name: 'Ecobee Mode'
entity_id: climate.home
automation:
- alias: NOTIFICATION Ecobee Mode Changes
trigger:
platform: state
entity_id: sensor.ecobeemode
action:
- service: notify.slack
data:
title: 'Heater Mode Changed'
message: 'Ecobee Heater set to {{ state_attr("climate.home","preset_mode") }}, {{now().strftime("%A %H:%M:%S %d-%m-%Y")}}'
None of those are triggers.
You should use state and then conditions…
petro
(Petro)
September 2, 2019, 2:37pm
4
try this
automation:
- alias: NOTIFICATION Ecobee Mode Changes
trigger:
- platform: template
value_template: >
{{ state_attr('climate.home', 'preset_mode') in ['away','home','tranisition', 'sleep'] }}
action:
- service: notify.slack
data:
title: 'Heater Mode Changed'
message: 'Ecobee Heater set to {{ state_attr("climate.home","preset_mode") }}, {{now().strftime("%A %H:%M:%S %d-%m-%Y")}}'
these states may be wrong, you need to look at preset_mode and use the exact verbiage & capitalization.
['away','home','tranisition', 'sleep']
This should work for you. Your other method may not be working because you are returning a string with the value true vrs returning nothing (when false). The returning nothing portion may break the automation. The template I provided will always return a true or false.
2 Likes
sebdoan
(Sebastian Doan)
September 11, 2019, 10:25pm
5
I’ll give your code a go and report back over the weekend. Thx.
mr_white
(Martin)
October 21, 2019, 8:19pm
6
hello.
nothing to do with the basic problem but you forgot the „sensors:“
sensor:
- platform: template
# here:
sensors:
ecobeemode:
value_template: '{{states.climate.home.attributes.preset_mode }}'
friendly_name: 'Ecobee Mode'
entity_id: climate.home
for me this automation works with the template sensor from @sebdoan , i just do it over the soundbox:
- alias: tvlight_dim
trigger:
platform: state
entity_id: sensor.sonosmode
to: 'TV'
condition:
- condition: state
entity_id: media_player.wohnzimmer
state: playing
action:
- service: hue.hue_activate_scene
data:
group_name: Wohnzimmer
scene_name: Fernsehn
greez