From 965ac82894fd7addcb7b9826c69d52dc72730142 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 10 Oct 2015 00:07:05 +0200 Subject: [PATCH] Add an example for the cookbook --- .../automation_for_rainy_days.markdown | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 source/cookbook/automation_for_rainy_days.markdown diff --git a/source/cookbook/automation_for_rainy_days.markdown b/source/cookbook/automation_for_rainy_days.markdown new file mode 100644 index 0000000000..8af1d00929 --- /dev/null +++ b/source/cookbook/automation_for_rainy_days.markdown @@ -0,0 +1,57 @@ +--- +layout: page +title: "Automation for rainy days" +description: "Basic example how to use weather conditions to set states" +date: 2015-10-08 19:05 +sidebar: false +comments: false +sharing: true +footer: true +--- + +### Rainy Day Light ### + +This requires a [forecast.io](components/sensor.forecast.html) 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. + +```yaml +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: + execute_service: light.turn_on + service_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. + +```yaml + 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: + execute_service: light.turn_off + service_entity_id: light.couch_lamp +``` +