The problem shows up if I turn the switch on manually, the automation never turns it off. The state changes are seen in states panel. I have tested the temperature component and if not manually activated they work properly. Am I correct in understanding the automation should over ride the manual activation? If not, how would I correct the errored state automatically?
Invalid config for [automation]: [state] is an invalid option for [automation]. Check: automat
ion->trigger->0->state. (See /config/configuration.yaml, line 426). Please check the docs at https://home-assistant.io/components/automation/
I have also tried āONā to exactly match the MQTT payload. The status in the states panel is on, lower case. Do I need to use a to and from pair?
I should really build the opposite safe guard into the other state as well. Thanks for the tip. Can you tell me why you suggested 2 timer checks? I will still need the triggers to turn it on and off for everyday automationā¦
Me? I went with a couple of examples of possible durations thatād work. Thereās other ways of doing it, including using a time trigger to run the automation every half hour:
Itāll check every half hour if the temperature has been above the target for 10 minutes and the switch is on. Pick intervals and durations that suit (or no duration if that suits).
Iād recommend using this automation with the time trigger, and add the temp threshold trigger too. I canāt see any case where this would actually be better than your previous version, but it just strikes me as āsaferā because it runs every half hour. I almost proposed the time trigger myself, but deleted my reply because I thought I was being nit-picky!
Thanks for being patient.
I am a relative newb at writing rules that must work. This is a backup to heat tape to prevent a pipe from freezing. I was hoping that there was a way to prevent worst caseā¦ For example if wifi drops as the threshold is crossed from high to low, that once wifi comes back the automation would check for a temperature below some point and would fire the on again every 15 or 20 minutes while the temp is below the trigger point. It almost looks like the last example from Tinkerer might do that, am I correct?
The most recent example by @tinkerer will check every thirty minutes if the temperature has been above 15 for at least ten minutes, and if the heater is on. If both of those are true, it will turn off the switch. I think they may have had an error in their condition though, because to use two conditions you need to specify if itās an āandā case or an āorā case.
This example does the same, but also will trigger as soon as the heater has been above 15 for ten minutes, and it will fire every 30 minutes. So it will fire as soon as itās been warm for ten minutes, but will also check every 30 minutes just in case the system somehow missed the temperature threshold being crossed.
So, my lack of skills with complex automations is starting to really show. I have written test automations for both on and off and have them passing yaml muster in configurator. But I am getting an error that does not make sense to me. I get the log entry once for each automation, it is clear to me that it does not like the āforā lines 18 and 45. Looking thru the HA docs it seems that this is a valid option for state, could it not be for numeric_state? I have tried it with ticks on and off of the ābelowā and āaboveā values as well. I have also tried ticks on and off for the minutes value under the āfor:ā
This is exactly what I am trying to achieve.
2018-01-11 22:58:03 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->condition->0->conditions->0->for. (See /config/
configuration.yaml, line 430). Please check the docs at https://home-assistant.io/components/automation/
2018-01-11 22:58:03 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->condition->0->conditions->0->for. (See /config/
configuration.yaml, line 430). Please check the docs at https://home-assistant.io/components/automation/
So, this automation works great! I have shortened timers to test for functionality. I have also commented the code and would like to post it up to help others in the future. I think I have the comments correctly defined.
Is the conditional numeric_state redundant since there is a trigger that checks the temp as well? I think it will look to see if the temp is above or below the set threshold for X minutes before falling to the conditions.
Also, multiple triggers work as an andāed pair? If one is not met, then the automation never falls thru to the conditions? Can triggers be built in an orāed configuration?
I really love this forum, I would not be nearly as far along without the help and support of the awesome members here!
Here is my commented code, hope it helps someone like me in the future!
- id: "Basement heat on timer test"
alias: 'Basement heat on timer test'
trigger:
- platform: time
minutes: '/3'
seconds: '00'
# Trigger every X minutes, "/" causes repeating trigger
- platform: numeric_state
entity_id: sensor.pws_temp_f
below: '24'
for:
minutes: 2
# Trigger based on WU temp below X and has been for Y minutes
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sensor.pws_temp_f
below: '24'
# Verify WU temp below X
- condition: state
entity_id: switch.basement_power
state: 'off'
# Verify switch is really off
action:
- service: switch.turn_on
data:
entity_id: switch.basement_power
# Set switch to correct state "ON"
I am also posting another automation that may interest folks. The first one looks at the temp and turns on the switch. The second one looks for a button press (maybe an accident), a state transition and the temperature and then corrects the state of the switch. I can see a use for this as well, so I am posting it up as well.
With both automations you will need one for each desired state ABOVE and BELOW. Both have correct yaml and have been tested and seem to work as desired.
- id: "Basement heat on"
alias: 'Basement heat on'
trigger:
- platform: numeric_state
entity_id: sensor.pws_temp_f
below: 20
# Temp is low
action:
- service: switch.turn_on
data:
entity_id: switch.basement_power
# Turn it on
- id: "Basement heat on guard"
alias: 'Basement heat on guard'
#Guard against button press on Sonoff
trigger:
- platform: state
entity_id: switch.basement_power
from: 'on'
to: 'off'
for:
minutes: 2
# Did switch transition from ON to OFF for a duration of 2 minutes?
- platform: state
entity_id: switch.basement_power
from: 'on'
to: 'off'
for:
minutes: 3
# Did switch transition from ON to OFF for a duration of 3 minutes?
condition:
- condition: numeric_state
entity_id: sensor.pws_temp_f
below: 20
#Verify below WU temp threshold
action:
- service: switch.turn_on
data:
entity_id: switch.basement_power
# Turn it back on
Once again, many thanks for the education. Now if only I could get some form of automated backup working that does not depend upon a windows machine with power shell up and runningā¦