auto-mixin¶
Timer Switch Service¶
Service that allows turn switch for only specified time.
Configuration parameters¶
- name: (required) The name of the service.
- switch: (required) ID of the switch component.
Sample configurations¶
timer_switch_service_basic¶
Source configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | device:
timer_switch_service_basic:
board: nodemcuv2
mixins:
- kind: gpio_relay_switch
name: test
pin: D3
- kind: timer_switch_service
name: test_timer
switch: test_switch
networks:
- api_password: api-pass
essid: wlan-essid
key: wlan-key
|
The rendered configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | api:
password: api-pass
services:
- service: test_timer
then:
- switch.turn_on:
id: test_switch
- logger.log:
args: interval
format: Service test_timer turned on test_switch for %ds.
- delay: !lambda "return interval * 1000;"
- switch.turn_off: test_switch
- logger.log: Service test_timer turned off test_switch.
variables:
interval: int
esphome:
board: nodemcuv2
name: timer_switch_service_basic
platform: ESP8266
logger:
esp8266_store_log_strings_in_flash: false
level: DEBUG
switch:
- id: test_switch
name: test_switch
pin: D3
platform: gpio
wifi:
domain: .local
fast_connect: true
networks:
- password: wlan-key
ssid: wlan-essid
|