summaryrefslogtreecommitdiffstats
path: root/blueprints/script/devices/aircon.yaml
blob: b2641be9cff1dfd86942aca268a8074396219073 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
blueprint:
  name: AirCon
  description: Stream photos from security camera
  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"

#  - if:
#      - condition: state
#        entity_id: switch.bedroom_aircon
#        state: 'off'
#    then:
#      - service: switch.turn_on
#        data: {}
#        target:
#          entity_id: switch.bedroom_aircon
#      - delay:
#          hours: 0
#          minutes: 0
#          seconds: 5
#          milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.hyundai_aircon_cool_18
    metadata: {}
mode: single