Automation - light Color change with weather forecast using switches. Need help!

OK I have switched over to the format and it isn’t triggering a change in light when the state changes on my weather. What do you think is going on?

alias: Aquarium New
description: Weather based on weather code openweather
triggers:
  - at: "12:00:00"
    id: "on"
    trigger: time
  - event: sunset
    offset: "-01:00:00"
    id: sunset -1
    trigger: sun
  - at: "22:00:00"
    id: "off"
    trigger: time
  - entity_id:
      - weather.forecast_home
    id: Weather Change
    trigger: state
    from: null
    to: null
  - event: sunset
    offset: "01:00:00"
    id: Sunset +1
    trigger: sun
conditions:
  - condition: state
    entity_id: input_boolean.automations_kill_switch
    state: "off"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
        sequence:
          - data: {}
            target:
              entity_id: switch.aquariumlight
            action: switch.turn_on
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
          - data: {}
            action: switch.turn_on
            target:
              entity_id: switch.aqled_sunrise
        alias: Turn Light on in Morning
      - conditions:
          - condition: trigger
            id:
              - sunset -1
        sequence:
          - data: {}
            target:
              entity_id: switch.aqled_sunrise
            action: switch.turn_on
        alias: Sunset Light -1 Hour
      - conditions:
          - condition: trigger
            id: "off"
        sequence:
          - data: {}
            target:
              entity_id: switch.aquariumlight
            action: switch.turn_off
        alias: Turn Off Light
      - conditions:
          - condition: trigger
            id:
              - Weather Change
          - condition: sun
            before: sunset
            before_offset: "-1:00:00"
        sequence:
          - target:
              entity_id: |
                switch.aqled_{{ state_to_switch[trigger.to_state.state] }}
            action: switch.turn_on
        alias: When weather changes during day
      - conditions:
          - condition: trigger
            id:
              - Sunset +1
        sequence:
          - metadata: {}
            data: {}
            target:
              entity_id: switch.aqled_bluemoon
            action: switch.turn_on
        alias: Turn blue after sunset +1 hour
      - conditions:
          - condition: trigger
            id:
              - Weather Change
          - condition: sun
            after: sunset
            after_offset: "1:00:00"
          - condition: time
            before: "22:00:00"
        sequence:
          - target:
              entity_id: |
                switch.aqled_{{ state_to_switch[trigger.to_state.state] }}
            action: switch.turn_on
        alias: Weather Change at night
      - conditions: []
        sequence: []
    default:
      - variables:
          state_to_switch:
            clear-night: bluemoon
            cloudy: >-
              {{ 'partlcloud' if is_state('sun.sun', 'above_horizon') else
              'greymoon' }}
            fog: partcloud2
            hail: tstrom
            lightning: tstrom
            lightning-rainy: tstrom2
            partlycloudy: partcloud2
            pouring: tstrom2
            rainy: tstrom
            snowy: partcloud
            snowy-rainy: tstorm
            sunny: sun
            windy: sun
            windy-variant: sun
            exceptional: sun
mode: single

I figured it out with this. Major misspelling and variables in the wrong section

alias: aaa
description: Weather based on weather code openweather
triggers:
  - entity_id:
      - weather.forecast_home
    id: Weather Change
    trigger: state
conditions: []
actions:
  - variables:
      state_to_switch:
        clear-night: bluemoon
        fog: cloudy2
        hail: partcloud2
        lightning: tstormsun
        lightning-rainy: tstorm
        partlycloudy: partcloud
        pouring: tstorm2
        rainy: tstorm
        snowy: cloudsun
        snowy-rainy: tstorm
        sunny: sun
        windy: white
        windy-variant: cloudsun
        exceptional: sun
        cloudy: "{{ 'cloudy' if is_state('sun.sun', 'above_horizon') else 'greymoon' }}"
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Weather Change
        sequence:
          - target:
              entity_id: |
                switch.aqled_{{ state_to_switch[trigger.to_state.state] }}
            action: switch.turn_on
        alias: When weather changes during day
    default: null
mode: single

1 Like