home-assistant.io/source/_cookbook/automation_for_rainy_days.markdown
Franck Nijhof ada7cc55a4 Entity Component to no longer generate automatic groups (#11662)
* Entity Component to no longer generate automatic groups

* Entity Component to no longer generate automatic groups
2020-01-07 18:00:45 +01:00

1.2 KiB

title, description, ha_category
title description ha_category
Automation for rainy days Basic example how to use weather conditions to set states Automation Examples

This requires a Dark Sky sensor with the condition precip_intensity that tells if it's raining or not. You could also experiment with other attributes such as cloud_cover.

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.precip_intensity
        to: 'rain'
    condition:
      - condition: state
        entity_id: all
        state: 'home'
      - condition: time
        after: '14:00'
        before: '23:00'
    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.

  - alias: 'Rain is over'
    trigger:
      - platform: state
        entity_id: sensor.precip_intensity
        to: 'None'
    condition:
      - condition: sun
        after: 'sunset'
        after_offset: '-01:00:00'
    action:
      service: light.turn_off
      entity_id: light.couch_lamp