Thanks for the assurance with this, I ran the automation manually instead of waiting for trigger point. I will try it again with condition triggers and report back.
If you want to test the automation’s State Trigger but not wait for the value of the sensor’s active_peak attribute to change to on_peak, you can manually set the value (the new value is temporary but sufficient to “force” a trigger).
Go to Developer Tools > States
Find sensor.toronto_hydro_electric_system_limited_residential_rate in the list and click it.
Scroll to the top of the page where all of the sensor’s properties are displayed in a form.
Take note of the current value of active_peak (perhaps make a copy of it)
Change the value of active_peak to on_peak
Click the Set State button
That should trigger your automation. Use the same method to set the attribute back to its original value.
Tried those steps in developer tools but it would not trigger and state change back very quickly. I guess will wait to confirm full function till state changes tomorrow from addon for hydro rate.
No, because the purpose of an automation’s condition is to determine if the automation should, or should not, execute its actions.
What you can do is move the conditional logic out of condition and into action. Specifically into an if-then-else.
alias: example
trigger:
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: on_peak
condition: []
action:
- if:
- condition: state
entity_id: climate.my_ecobee_3
state: heat
- condition: numeric_state
entity_id: sensor.toronto_temperature
below: -1
then:
- service: climate.set_aux_heat
target:
device_id: e144dbd5b26383e5540eb630baa31d66
entity_id: climate.my_ecobee_3
data:
aux_heat: true
else:
- service: notify.notify
data:
message: "Currently on peak but conditions were not met."
BTW, the climate.set_aux_heat service call is setting two entities, one by entity_id and another by device_id. Are they in fact two different entities?
Thanks again for your help, I implanted the changes you provided on the example. I also eliminated the service call for climate having device and entity id and just have entity id now. Will see how it works through the rate changes through the day.
I think I have most of most of the logic flow worked out and automation to turn on and off Aux heat based on TOU rate and weather seems to be working. I would just like to add one more condition on setting back from Aux to heat pump heat where it checks detla between current_temperature and set temperature attributes on Ecobee so if the delta is more than 1 it keeps Aux running. Any help with adding this check will be greatly appreciated.
description: ""
trigger:
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: on_peak
condition: []
action:
- if:
- condition: state
entity_id: climate.my_ecobee_3
state: heat
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.toronto_temperature
below: -1
- condition: state
entity_id: weather.toronto
state: snowy
- condition: numeric_state
entity_id: sensor.toronto_humidity
above: 90
enabled: true
then:
- service: climate.set_aux_heat
data:
aux_heat: true
target:
entity_id: climate.my_ecobee_3
- service: notify.notify
data:
message: Ecobee switched from Heat Pump heating to Aux heating.
title: Aux Heat
else:
- service: notify.notify
data:
message: >-
Ecobee remained on Heat Pump heating, conditions were not met to
switch to Aux Heat.
title: Aux Heat
mode: single
alias: Aux Off non-peak rate
description: ""
trigger:
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: off_peak
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: mid_peak
- platform: state
entity_id:
- climate.my_ecobee_3
attribute: aux_heat
to: "on"
condition: []
action:
- if:
- condition: numeric_state
entity_id: sensor.toronto_temperature
above: -5
then:
- service: climate.set_aux_heat
data:
aux_heat: false
target:
entity_id: climate.my_ecobee_3
- service: notify.notify
data:
message: Ecobee switched from Aux heating heating to Heat Pump.
title: Aux Heat
else:
- service: notify.notify
data:
message: >-
Ecobee remained on Aux heating, conditions were not met to switch to
Heat Pump.
title: Aux Heat
mode: single
I think I have most of the logic flow worked out and automation to turn on and off Aux heat based on TOU rate and weather seems to be working. I would just like to add one more condition on setting back from Aux to heat pump heat where it checks detla between current_temperature and set temperature attributes on Ecobee so if the delta is more than 1 it keeps Aux running. Any help with adding this check will be greatly appreciated.
description: ""
trigger:
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: on_peak
condition: []
action:
- if:
- condition: state
entity_id: climate.my_ecobee_3
state: heat
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.toronto_temperature
below: -1
- condition: state
entity_id: weather.toronto
state: snowy
- condition: numeric_state
entity_id: sensor.toronto_humidity
above: 90
enabled: true
then:
- service: climate.set_aux_heat
data:
aux_heat: true
target:
entity_id: climate.my_ecobee_3
- service: notify.notify
data:
message: Ecobee switched from Heat Pump heating to Aux heating.
title: Aux Heat
else:
- service: notify.notify
data:
message: >-
Ecobee remained on Heat Pump heating, conditions were not met to
switch to Aux Heat.
title: Aux Heat
mode: single
alias: Aux Off non-peak rate
description: ""
trigger:
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: off_peak
- platform: state
entity_id:
- sensor.toronto_hydro_electric_system_limited_residential_rate
attribute: active_peak
to: mid_peak
- platform: state
entity_id:
- climate.my_ecobee_3
attribute: aux_heat
to: "on"
condition: []
action:
- if:
- condition: numeric_state
entity_id: sensor.toronto_temperature
above: -5
then:
- service: climate.set_aux_heat
data:
aux_heat: false
target:
entity_id: climate.my_ecobee_3
- service: notify.notify
data:
message: Ecobee switched from Aux heating heating to Heat Pump.
title: Aux Heat
else:
- service: notify.notify
data:
message: >-
Ecobee remained on Aux heating, conditions were not met to switch to
Heat Pump.
title: Aux Heat
mode: single
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title and add a link to your first post that leads to the Solution. This helps users find answers to similar questions.
Give me a few minutes. The community forum is sluggish (reportedly under heavy load; you may have noticed that your last post was duplicated) and posting is challenging.
EDIT 1
Use this service call in your automation. The template return a boolean true (aux heat on) if the delta is greater than 1 otherwise it returns boolean false (aux heat off).
- service: climate.set_aux_heat
data:
aux_heat: >
{% set thermostat = 'climate.my_ecobee_3' %}
{% set current = state_attr(thermostat, 'current_temperature') %}
{% set target = state_attr(thermostat, 'temperature') %}
{{ target - current > 1 }}
target:
entity_id: climate.my_ecobee_3
EDIT 2
Amendment. Added the balance of the service call, namely the target.
EDIT 3
Correction. Added missing closing parenthesis on lines 2 and 3 of the aux_heat template.
I had only posted part of the service call (the part that should be changed). However I see how that can be misleading so I have amended my original example so that it now includes the entire service call (i.e. including the target part).
Getting error saving the updated code indicating "Message malformed: template value should be a sting for dictionary value @ data [‘action’][0][‘then’][0][‘data’]. Any idea why that is happening?
Message malformed: template value should be a sting
The error message appears to indicate that it wants the template to report a string value as opposed to what it’s currently doing (reporting a boolean value). Worst case is the aux_heat option doesn’t support templates but let’s assume it does for now.
Replace:
{{ target - current > 1 }}
with:
{{ 'true' if target - current > 1 else 'false' }}
I have a feeling that Home Assistant’s native typing feature will convert the string true to a boolean true and result in the same error message. Anyway, try it and let me know the result.
The latest error message identifies a problem that also existing in the original example I had posted. There’s a missing closing parenthesis on this line:
{% set current = state_attr(thermostat, 'current_temperature' %}
^
|
There should be a ) right here -----
and the next line:
{% set target = state_attr(thermostat, 'temperature' %}
^
|
There should be a ) right here -----
I recommend you make the corrections in the “brute-force” version. If that satisfies Home Assistant, I suggest you make the same corrections in the original, non-brute-force version (which is less verbose).
I have corrected the suggested service call posted above but here it is again with the closing parenthesis.
- service: climate.set_aux_heat
data:
aux_heat: >
{% set thermostat = 'climate.my_ecobee_3' %}
{% set current = state_attr(thermostat, 'current_temperature') %}
{% set target = state_attr(thermostat, 'temperature') %}
{{ target - current > 1 }}
target:
entity_id: climate.my_ecobee_3