HA change light color if weather forecast changes

Hey guys, I just started using HA because IFTTT started changing 1.99 to do 2 simples tasks that I use it for.
1 of them im not getting right on HA, and I need some help.
I have a led strip using fluxled. I made the script to change color and etc. It works great.
Now when I make the automation, it just does not work. The automations does not see the change on the weather state

"- id: xxxx

alias: livingroom_cloudy

description: ''

trigger:

- platform: state

entity_id: [weather.casa]

to: partlycloudy

attribute: forecast

- platform: state

entity_id: [weather.casa]

to: cloudy

condition: []

action:

- service: script.casa_nublado

data: {}

- service: notify.mobile_app_sm_n9600

data:

message: O tempo da casa mudou para nublado.

mode: single"

Is there anything wrong with this code? Or any ideas to improve it?
Thanks

I see multiple issues, e.g. entity ahould not be enclosed by square brackets. But first you need to format the code correctly, otherwise we can’t see possible indentation errors. See point 11 here to learn how to fornat the code properly.

my bad, I was editing it on notepad.

- id: '1601524132255'
  alias: livingroom_cloudy
  description: ''
  trigger:
  - platform: state
    entity_id: weather.casa
    to: partlycloudy
  - platform: state
    entity_id: weather.casa
    to: cloudy
  - platform: state
    entity_id: weather.casa
    to: partly cloudy
    attribute: forecast
  condition: []
  action:
  - service: script.casa_nublado
    data: {}
  - service: notify.mobile_app_sm_n9600
    data:
      message: O tempo da casa mudou para nublado.
  mode: single

Does the automation work if you execute it manually?

Are you sure that the forecast attribute changes to partly cloudy and not partlycloudy?

Yeap, it works if i run it manually.
I’m using both forecasts, with and without the space in the middle just to make sure

Is the automation enabled? Can you double check that weather casa changes to “cloudy” in Developer Tools -> States?

yeap it enabled and it changes to cloudy and partlycliudy (with no space)

Any errors in the logs? I can’t see any issue with the code. Can you show a snippet of the entity under Developer Tools -> States and post it here?

Hi,
I’m also using the weather forecast to change the lights , but I use the weather status to show in color scale the forecast , where Rain=Red , Clear Sky = Blue , Cloudy and windy = Green

check this

- alias: sensor.galoe PIR turn_on light.galo motion_detected
  trigger:
    platform: state
    entity_id: sensor.hall_pir
    to: 'ON'
  action:
  - service: mqtt.publish
    data_template:
      topic: cmnd/stationhall/Color
      payload: '{% if is_state("sensor.openw_forecast", "Clear") %} {0,0,250} {% elif
        is_state("sensor.openw_forecast", "clear sky") %} {0,0,250} {%-elif is_state("sensor.openw_forecast",
        "broken clouds") %}{0,100,250} {%-elif is_state("sensor.openw_forecast", "scattered
        clouds") %} {60,100,250} {%-elif is_state("sensor.openw_forecast", "few clouds")
        %} {50,50,250} {%-elif is_state("sensor.openw_forecast", "Clouds") %} {0,250,0}
        {%-elif is_state("sensor.openw_forecast", "overcast clouds") %} {0,250,0}
        {%-elif is_state("sensor.openw_forecast", "Rain") %} {250,0,0} {%-elif is_state("sensor.openw_forecast",
        "rain") %} {250,0,0} {%-elif is_state("sensor.openw_forecast", "shower rain")
        %} {250,100,0} {%-elif is_state("sensor.openw_forecast", "light rain") %}
        {250,0,100} {%-elif is_state("sensor.openw_forecast", "moderate rain") %}
        {250,150,0} {%-elif is_state("sensor.openw_forecast", "Snow") %} {250,0,0}
        {% endif %}

        '
1 Like
temperature: 22.2
humidity: 86
pressure: 1018
wind_bearing: 119.8
wind_speed: 24.1
attribution: >-
  Weather forecast from met.no, delivered by the Norwegian Meteorological
  Institute.
forecast:
  - condition: partlycloudy
    temperature: 27.1
    templow: 20.8
    datetime: '2020-10-05T15:00:00+00:00'
    wind_bearing: 116.6
    wind_speed: 22.7
  - condition: sunny
    temperature: 30.6
    templow: 21.5
    datetime: '2020-10-06T15:00:00+00:00'
    wind_bearing: 150
    wind_speed: 21.6
  - condition: partlycloudy
    precipitation: 0.2
    temperature: 24.6
    templow: 22.2
    datetime: '2020-10-07T15:00:00+00:00'
    wind_bearing: 148.7
    wind_speed: 19.8
  - condition: partlycloudy
    precipitation: 0.2
    temperature: 24.2
    templow: 22
    datetime: '2020-10-08T15:00:00+00:00'
    wind_bearing: 180.6
    wind_speed: 20.2
  - condition: rainy
    precipitation: 1.7
    temperature: 24.5
    templow: 22.5
    datetime: '2020-10-09T15:00:00+00:00'
    wind_bearing: 135.3
    wind_speed: 18.7
friendly_name: Casa

There are no error on the logs but I think i just found my mistake.
I’m using attribute forecast on my code. I think thats it. I’ll remove and wait a bit to see if it works.

You only use it in your third trigger, not in the first two triggers. So when the state, not any of the attributes, changes to “cloudy” or “partlycloudy” it should trigger.

Thanks for the help.
It worked like a charm now.

the problem was the “attribute: forecast” line.
it should be empty