home-assistant.io/source/_cookbook/automation_for_rainy_days.markdown
Fabian Affolter 79b279bdb6 Update link
2016-02-28 11:38:09 +01:00

1.3 KiB

layout, title, description, date, sidebar, comments, sharing, footer, ha_category
layout title description date sidebar comments sharing footer ha_category
page Automation for rainy days Basic example how to use weather conditions to set states 2015-10-08 19:05 true false true true Automation Examples

This requires a forecast.io sensor with the condition weather_precip that tells if it's raining or not.

Turn on a light in the living room when it starts raining, someone is home, and it's afternoon or later.

automation:
  alias: 'Rainy Day'

  trigger:
       - platform: state
         entity_id: sensor.weather_precip
         state: 'rain'
       - platform: state
         entity_id: group.all_devices
         state: 'home'
       - platform: time
         after: '14:00'
         before: '23:00'

  condition: use_trigger_values

  action:
    service: light.turn_on
    entity_id: light.couch_lamp

And then of course turn off the lamp when it stops raining but only if it's within an hour before sunset.

automation 2:
  alias: 'Rain is over'
  trigger:
       - platform: state
         entity_id: sensor.weather_precip
         state: 'None'
       - platform: sun
         event: 'sunset'
         offset: '-01:00:00'

  condition: use_trigger_values
  action:
    service: light.turn_off
    entity_id: light.couch_lamp