I am new to this and tried searching for related issues, but I didn’t see any.
I am simply trying to activate/deactivate my Kasa outlets in my greenhouse based on timed checks of the weather.forecast_home_hourly entity.
To activate, I have the plug set to check the weather.forecast_home_hourly every 30 minutes to see if the current temp is below 36 degrees:
alias: Tree Lights On
description: "Turn lights on to warm trees."
trigger:
- platform: time_pattern
minutes: "30"
condition:
- condition: numeric_state
entity_id: weather.forecast_home_hourly
attribute: temperature
below: 36
action:
- type: turn_on
device_id: 4ef0a41a0f39bee838dccbc223d01ba1
entity_id: switch.right_plug
domain: switch
mode: single
And to turn off the plug:
alias: Tree Lights Off
description: Turn off tree warming lights.
trigger:
- platform: time_pattern
minutes: "45"
condition:
- condition: numeric_state
entity_id: weather.forecast_home_hourly
attribute: temperature
above: 35
action:
- type: turn_off
device_id: 4ef0a41a0f39bee838dccbc223d01ba1
entity_id: switch.right_plug
domain: switch
mode: single
I have tested this a lot the last two weeks. The plug and lights turn off accurately, but they don’t seem to activate correctly, and I always end up manually activating the lights. Can anyone give me some tips on reliably activating these lights based on current temps?
That trigger is not for “every 30 minutes”, it’s for “on the 30th minute of every hour”.
Can you clarify the behavior you are looking for?
AFAIK, the attribute you are using as a condition only changes once an hour around the top of the hour, so checking it at 30 and 45 minutes past the hour is kind of pointless.
Thank you for the reply, so this should be set to 0 or 1 for top of the hour? I thought it was a time interval.
The behavior that I am looking for is to check weather.forecast_home_hourly at some point every hour, turn on my smart plug when temperature goes bellow 36° and turn off the plug when it goes above 35 °.
Is there a better attribute and condition that I should use instead?
So I originally did all of these setting in the GUI and not YAML, so these were added in by the GUI. Is it ok to edit that out then or will it mess anything up?
Home Assistant’s automation system is based on events, it is rare for Time Pattern triggers to be necessary. Instead of checking multiple times an hour, use a Numeric State trigger to listen for the event of the temperature crossing you desired threshold.
alias: Tree Lights On
description: "Turn lights on to warm trees."
triggers:
- trigger: numeric_state
entity_id: weather.forecast_home_hourly
attribute: temperature
below: 36
conditions: []
actions:
- action: switch.turn_on
target:
entity_id: switch.right_plug
mode: single