Can someone assist me in finding out why my weather.home state is not being correctly triggered in my simple automation to turn on a light if state = rainy?
- id: '1582412854778'
alias: Lights - Kitchen RGB Blue If Rainy
description: ''
trigger:
- platform: state
entity_id: weather.home
to: rainy
condition: []
action:
- data:
effect: blue_fade
service: light.turn_on
target:
entity_id: light.kitchen_rgb_led
- delay: 00:15:00
- entity_id: light.kitchen_rgb_led
service: light.turn_off
mode: single
I can’t see anything wrong with my automation yet it never triggers:
The following means you want the State Trigger to trigger when the state changes torainy.
to: rainy
In other words, it will trigger when it changes from some other state torainy. If this automation was created while the state was rainy the State Trigger will not trigger. It triggers only on the transition from one state to another (rainy).
That was my thought also but I have left this on for a few days and the states changed in the meantime but the automation never fired so I wonder if I need to create a new sensor templated from the weather state because using weather.home doesn’t actually give back “rainy” as the state?
Thanks for the results of your tests; clearly there’s an issue with the State Trigger.
Go to Developer Tools > States
Select weather.home
Replace rainy with sunny
Click Set State
Repeat the steps but this time, in step 3, replace sunny with rainy (and then click Set State).
When I do this on my system, the moment the state changes from sunny to rainy it triggers the automation (I created a simple automation with the same State Trigger as in your automation).
Ok so I did that and it didn’t turn on the light, then I deleted the automation and created a new one and then the same test actually worked.
I can only think that something went wrong when I originally created the automation.
But hey it works now so it’s all good.
Thanks for the assist
The original State Trigger you created looked good and should have worked so the only thing I can think of is that there might have been a non-printable character somewhere in the rainy string. It would have prevented the State Trigger from ever matching weather.home's state.
Anyway, should you ever encounter a similar problem (where a trigger really should work, but doesn’t), you now know the steps for debugging it.