summaryrefslogtreecommitdiffstats
path: root/blueprints/script/devices/aircon.yaml
blob: 1677c69b2bb75c47be9eae67d8dfe3bf52d726d7 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
blueprint:
  name: AirCon
  description: Automatically on/off Air Condition (current state and temperature based)
  domain: script
  input:
    power:
      name: Power
      description: Aircon Smart Power Plug
      selector:
        entity:
          domain: switch
    temperature:
      name: Temperature
      description: Temperature sensor
      selector:
        entity:
          domain: sensor
          device_class: temperature
    cold_temp:
      name: Cold Temp
      description: Temperature threshold to turn on heating
      default: 16
      selector:
        number:
          min: 8
          max: 20
          unit_of_measurement: C
    hot_temp:
      name: Hot Temp
      description: Temperature threshold to turn on cooling
      default: 20
      selector:
        number:
          min: 20
          max: 36
          unit_of_measurement: C
    cool_scene:
      name: Cool Scene
      description: Cooling scene of Aircon
      selector:
        entity:
          domain: scene
    heat_scene:
      name: Heat Scene
      description: Warming scene of Aircon
      selector:
        entity:
          domain: scene
    off_scene:
      name: Off Scene
      description: Off scene of Aircon
      selector:
        entity:
          domain: scene
    confirm:
      name: Confirm
      description: Confirmation script
      default: []
      selector:
        action:

variables:
  temp: !input temperature
  cold: !input cold_temp
  hot: !input hot_temp

alias: AirCon
sequence:
  - if:
      - condition: state
        entity_id: !input power
        state: 'on'
    then:
      - service: scene.turn_on
        target:
          entity_id: !input off_scene
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - service: switch.turn_off
        target:
          entity_id: !input power
    else:
      - service: switch.turn_on
        target:
          entity_id: !input power
      - delay:
          hours: 0
          minutes: 0
          seconds: 5
          milliseconds: 0
      - choose:
          - conditions: 
              - "{{ states('sensor.bedroom_temp_temperature') | float < cold }}"
            sequence:
              - service: scene.turn_on
                target:
                  entity_id: !input heat_scene
          - conditions: 
              - "{{ states('sensor.bedroom_temp_temperature') | float > hot }}"
            sequence:
              - service: scene.turn_on
                target:
                  entity_id: !input cool_scene
        default:
          - service: switch.turn_off
            target:
              entity_id: !input power
      - service: switch.turn_on
        target:
          entity_id: !input power
      - choose: []
        default: !input "confirm"

mode: single