/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Administration/SmartHome/Hass/examples/button-double-click.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2022-06-20 03:20:18 UTC
  • Revision ID: csa@suren.me-20220620032018-xquk369l0ukymgaa
Home Assistant

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Documentation
 
2
=============
 
3
 - We want a special action on double click on standard light switch which does not implement 'double click' or 'hold/release' triggers.
 
4
 - The concept is
 
5
    * To wait for 1 second for a new 'change state' trigger on the switch (with continue_on_timeout option)
 
6
    * If succesful 'wait.trigger' variable will be set to the appropriate trigger. Otherwise, it will be None
 
7
    * So, we perform 'special action' to turn all lights off if trigger is None
 
8
    * Otherwise, we perform standard actions
 
9
 
 
10
Code
 
11
====
 
12
alias: 'Hall Bulb: Entrance Combo'
 
13
description: ''
 
14
trigger:
 
15
  - platform: device
 
16
    type: changed_states
 
17
    device_id: 07b7086cf34752386c82a5109311ac6e
 
18
    entity_id: switch.0x0c4314fffe2061db_right
 
19
    domain: switch
 
20
    for:
 
21
      hours: 0
 
22
      minutes: 0
 
23
      seconds: 0
 
24
condition: []
 
25
action:
 
26
  - wait_for_trigger:
 
27
      - platform: device
 
28
        type: changed_states
 
29
        device_id: 07b7086cf34752386c82a5109311ac6e
 
30
        entity_id: switch.0x0c4314fffe2061db_right
 
31
        domain: switch
 
32
    timeout: '1'
 
33
    continue_on_timeout: true
 
34
  - if:
 
35
      - condition: template
 
36
        value_template: '{{ wait.trigger == None }}'
 
37
    then:
 
38
      - if:
 
39
          - condition: device
 
40
            type: is_on
 
41
            device_id: 07b7086cf34752386c82a5109311ac6e
 
42
            entity_id: switch.0x0c4314fffe2061db_right
 
43
            domain: switch
 
44
        then:
 
45
          - type: turn_on
 
46
            device_id: bf45f1d630db6e2aa1307866603f548a
 
47
            entity_id: light.smart_light
 
48
            domain: light
 
49
        else:
 
50
          - type: turn_off
 
51
            device_id: bf45f1d630db6e2aa1307866603f548a
 
52
            entity_id: light.smart_light
 
53
            domain: light
 
54
    else:
 
55
      - service: switch.turn_off
 
56
        data: {}
 
57
        target:
 
58
          entity_id: switch.all_lights
 
59
      - service: input_button.press
 
60
        data: {}
 
61
        target:
 
62
          entity_id: input_button.button_confirm
 
63
mode: single
 
64