Weather automation not working

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 to rainy.

    to: rainy

In other words, it will trigger when it changes from some other state to rainy. 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?

If the current state is rainy paste this into the Template Editor and it should report True.

{{ is_state('weather.home', 'rainy') }}

Yup it says True so that rules that out but still baffled as to why it doesn’t trigger then

Let’s get this one out of the way before exploring any further:

Is the automation turned on?

Yes and if I manual trigger it lights do come on.
image

Thanks for the results of your tests; clearly there’s an issue with the State Trigger.

  1. Go to Developer Tools > States
  2. Select weather.home
  3. Replace rainy with sunny
  4. Click Set State

Screenshot from 2021-03-10 08-38-35

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 :slight_smile:

1 Like

You’re welcome!

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.

Yeah for sure, teach a man how to fish and all that :slight_smile: