Automation to trigger a light when some weather conditions are detected. openweather api

Trying to create an automation to switch on a light during specific weather conditions using openweather API integration.
If I add all the triggers in 1 automation will this work? Will it trigger if any of these occur? (rain/fog/lightning/)

- id: '1630350392832'
  alias: Rain/Fog lights on
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.openweathermap_forecast_condition
    to: Mist
  - platform: state
    entity_id: sensor.openweathermap_condition
    to: fog
  - platform: state
    entity_id: sensor.openweathermap_condition
    to: pouring
  - platform: state
    entity_id: sensor.openweathermap_condition
    to: rainy
  - platform: state
    entity_id: sensor.openweathermap_condition
    to: lightning
  - platform: state
    entity_id: sensor.openweathermap_forecast_condition
    to: lightning-rainy
  condition:
  - condition: sun
    before: sunrise
    after: sunset
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.03052672ecfabc4350f1
  mode: single

Thanks

It should. You have six State Triggers, each listening for a specific state value.

You can also express those six State Triggers in one State Trigger like this:


  trigger:
  - platform: state
    entity_id: sensor.openweathermap_forecast_condition
    to:
    - 'Mist'
    - 'fog'
    - 'pouring'
    - 'rainy'
    - 'lightning'
    - 'lightning-rainy'

Thanks.

Gone a step further (just a little) with nodered - Can use specific codes here:

Your first post stated you were “Trying to create an automation”. Did you change your mind and switch to using Node-Red?

Maybe I should have phrased that better. Nodered flow to automate lights

It seems to me you phrased it quite accurately:

  1. Topic title requests “Automation to trigger …”
  2. Category is just Configuration (no Node-Red category included).
  3. First post asks “create an automation to switch on …”
  4. First post even includes an automation example.
  5. First post asks if the automation example will work.

First reply explains how to achieve your goal and then, out of left field, came your Node-Red spider-web flow. :man_shrugging:

3 Likes