Replace with new shorthand notation

This commit is contained in:
Otto Winter 2018-11-10 14:33:24 +01:00
parent 4504fff418
commit f28120baed
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
7 changed files with 28 additions and 55 deletions

View File

@ -255,8 +255,7 @@ So for example ``above: 5`` with no below would mean the range from 5 to positiv
above: 5
below: 10
then:
- switch.turn_on:
id: relay_1
- switch.turn_on: relay_1
Configuration variables:

View File

@ -37,7 +37,7 @@ This action toggles a switch with the given ID when executed.
on_...:
then:
- switch.toggle: id: relay_1
- switch.toggle: relay_1
.. _switch-turn_on_action:

View File

@ -18,11 +18,9 @@ as a switch and can be controlled through the frontend.
return false;
}
turn_on_action:
- switch.turn_on:
id: switch2
- switch.turn_on: switch2
turn_off_action:
- switch.turn_on:
id: switch1
- switch.turn_on: switch1
optimistic: true

View File

@ -23,27 +23,19 @@ for a short period of time, the close/open action begins.
name: "Garage Door"
open_action:
# Cancel any previous action
- switch.turn_off:
id: close_switch
- switch.turn_off: close_switch
# Turn the OPEN switch on briefly
- switch.turn_on:
id: open_switch
- switch.turn_on: open_switch
- delay: 0.1s
- switch.turn_off:
id: open_switch
- switch.turn_off: open_switch
close_action:
- switch.turn_off:
id: open_switch
- switch.turn_on:
id: close_switch
- switch.turn_off: open_switch
- switch.turn_on: close_switch
- delay: 0.1s
- switch.turn_off:
id: close_switch
- switch.turn_off: close_switch
stop_action:
- switch.turn_off:
id: close_switch
- switch.turn_off:
id: open_switch
- switch.turn_off: close_switch
- switch.turn_off: open_switch
optimistic: true
See Also

View File

@ -26,8 +26,7 @@ binary_sensor:
name: "Sonoff 4CH Button 1"
on_press:
then:
switch.toggle:
id: relay_1
switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO9
@ -36,8 +35,7 @@ binary_sensor:
name: "Sonoff 4CH Button 2"
on_press:
then:
switch.toggle:
id: relay_2
switch.toggle: relay_2
- platform: gpio
pin:
number: GPIO10
@ -46,8 +44,7 @@ binary_sensor:
name: "Sonoff 4CH Button 3"
on_press:
then:
switch.toggle:
id: relay_3
switch.toggle: relay_3
- platform: gpio
pin:
number: GPIO14
@ -56,8 +53,7 @@ binary_sensor:
name: "Sonoff 4CH Button 4"
on_press:
then:
switch.toggle:
id: relay_4
switch.toggle: relay_4
- platform: status
name: "Sonoff 4CH Status"

View File

@ -26,8 +26,7 @@ binary_sensor:
name: "Sonoff S20 Button"
on_press:
then:
- switch.toggle:
id: relay
- switch.toggle: relay
- platform: status
name: "Sonoff S20 Status"

View File

@ -52,8 +52,7 @@ For example, this configuration would achieve your desired behavior:
name: "Living Room Dehumidifier Toggle Button"
on_press:
then:
- switch.toggle:
id: dehumidifier1
- switch.toggle: dehumidifier1
@ -104,11 +103,9 @@ like so:
# ...
on_press:
then:
- switch.toggle:
id: dehumidifier1
- switch.toggle: dehumidifier1
- delay: 2s
- switch.toggle:
id: dehumidifier1
- switch.toggle: dehumidifier1
With this automation, a press on the push button would cause the dehumidifier to turn on/off for 2 seconds, and then
cycle back to its original state. Similarly you can have a single trigger with multiple automations:
@ -118,19 +115,15 @@ cycle back to its original state. Similarly you can have a single trigger with m
# ...
on_press:
- then:
- switch.toggle:
id: dehumidifier1
- switch.toggle: dehumidifier1
- then:
- light.toggle:
id: dehumidifier_indicator_light
- light.toggle: dehumidifier_indicator_light
# Same as:
on_press:
then:
- switch.toggle:
id: dehumidifier1
- light.toggle:
id: dehumidifier_indicator_light
- switch.toggle: dehumidifier1
- light.toggle: dehumidifier_indicator_light
As a last example, let's make our dehumidifier smart: Let's make it turn on automatically when the humidity a sensor
@ -145,12 +138,10 @@ reports is above 65% and make it turn off again when it reaches 50%
on_value_range:
- above: 65.0
then:
- switch.turn_on:
id: dehumidifier1
- switch.turn_on: dehumidifier1
- below: 50.0
then:
- switch.turn_off:
id: dehumidifier1
- switch.turn_off: dehumidifier1
temperature:
name: "Living Room Temperature"
@ -317,11 +308,9 @@ time period.
on_...:
then:
- switch.turn_on:
id: relay_1
- switch.turn_on: relay_1
- delay: 2s
- switch.turn_off:
id: relay_1
- switch.turn_off: relay_1
# Templated, waits for 1s (1000ms) only if a reed switch is active
- delay: !lambda "if (id(reed_switch).state) return 1000; else return 0;"