View difference between Paste ID: YhacvveT and YKqb0UTa
SHOW: | | - or go back to the newest paste.
1
blueprint:
2
  name: Coming Home
3
  description: Track when a person comes home
4
  domain: automation
5
  input:
6
  
7
    person:
8
      name: Person
9
      description: Person to track
10
      selector:
11
          target:
12
          
13
    persons_not_home:
14
      name: Persons not home
15
      description: Person which should not be home
16
      selector:
17
          target:
18
        
19
    delay_min:
20
      name: Delay minimum
21
      description: How short delay
22
      default: 10
23
      selector:
24
        number:
25
          min: 0
26
          max: 300
27
          mode: slider
28
          step: 10
29
          unit_of_measurement: "seconds"
30
 
31
    delay_max:
32
      name: Delay maximum
33
      description: How long delay
34
      default: 50
35
      selector:
36
        number:
37
          min: 10
38
          max: 600
39
          mode: slider
40
          step: 10
41
          unit_of_measurement: "seconds"
42
43
trigger:
44
  - platform: state
45
    entity_id: !input person
46
    to: home
47
48
mode: single
49
50
variables:
51
  person: !input person
52
  persons_not_home: !input persons_not_home
53
  delay_min: !input delay_min
54
  delay_max: !input delay_max
55
56
action:
57
  - delay: "{{ range(delay_min | int, delay_max | int) | random }}"
58
  - choose:
59
      - conditions:
60-
        - "{{ is_state(person, 'home') }}"
60+
        - condition: state
61-
        - "{{ is_state(persons_not_home, 'not_home') }}"
61+
          entity_id: "{{ person }}"
62
          state: "home"
63
        - condition: state
64
          entity_id: "{{ persons_not_home }}"
65
          state: "not_home"
66
        sequence:
67
          - service: mqtt.publish
68
            data:
69
                topic: home-assistant/turn_off
70
                payload: '1'