View difference between Paste ID: 9CvVa9tR and Y75VhTua
SHOW: | | - or go back to the newest paste.
1
## Creating Daikin AC remote in HA using broadlink pro IR Remote ##
2
# Basic idea is to use input_selects to choose the settings (mode/temp/fan speed) you want.
3
# Learn the broadlink IR codes for every AC setting you want available and save them as scripts with formulaic names.
4
#  A template sensor uses the input_select settings to show the correct script. 
5
# Turning on an input_boolean, triggers an automation. 
6
# The automation action turns on the correct script, causeing the correct IR Code to be sent.
7
8
input_boolean:
9
  aircon_change_settings:
10
    initial: off
11
    name: Change Aircon Settings
12
13
input_select: 
14
 aircon_mode:
15
  name: Aircon Mode
16
  options:
17
    - "Cool"
18
    - "Fan"
19
    - "Heat"
20
  icon: mdi:air-conditioner
21
22
aircon_speed:
23
  name: Fan Speed
24
  options:
25
    - "0"
26
    - "1"
27
    - "2"
28
    - "3"
29
    - "4"
30
    - "5"
31
  icon: mdi:fan
32
33
aircon_temp_cool: # Adjust to the temps you want available
34
  name: Cool Temp
35
  options:
36
    - "21"
37
    - "22"
38
    - "23"
39
    - "24"
40
    - "25"
41
    - "26"
42
  icon: mdi:snowflake
43
44
aircon_temp_heat:  # Adjust to the temps you want available
45
  name: Heat Temp
46
  options:
47
    - "14"
48
    - "15"
49
    - "16"
50
    - "17"
51
    - "18"
52
  icon: mdi:white-balance-sunny
53
54
script:  
55
## One script for each aircon setting, all following the format "aircon_m[mode]_t[temp]_s[speed] (fan excludes temp section). Need to learn IR Code for every setting you want to be able to set. Learn all codes from off position. i.e us AC remote to set temp/speed/mode, turn AC off, then learn the code from pressing the on button. Ensures that AC will turn on if off and that the code learned is for the exact settings you want. Also, learn the AC off code.
56
57
  aircon_off:
58
   sequence:
59
     - service: broadlink.send
60
       data:
61
         host: 192.168.1.4
62
         packet: 
63
           - 'IR CODE'
64
     - delay: "00:00:01"
65
66
  aircon_mfan_s1:
67
   sequence:
68
     - service: broadlink.send
69
       data:
70
         host: 192.168.1.4
71
         packet: 
72
           -  'IR CODE'
73
     - delay: "00:00:01"
74
  
75
  aircon_mfan_s2:
76
   sequence:
77
     - service: broadlink.send
78
       data:
79
         host: 192.168.1.4
80
         packet: 
81
           -  'IR CODE'
82
     - delay: "00:00:01"
83
84
  aircon_mcool_t21_s4:
85
   sequence:
86
     - service: broadlink.send
87
       data:
88
         host: 192.168.1.4
89
         packet: 
90
           -  'IR CODE'
91
     - delay: "00:00:01"
92
93
  aircon_mheat_t18_s2:
94
   sequence:
95
     - service: broadlink.send
96
       data:
97
         host: 192.168.1.4
98
         packet: 
99
           -  'IR CODE'
100
     - delay: "00:00:01"
101
102
sensor:
103
      aircon_settings:
104
        friendly_name: Aircon Settings
105
        entity_id: 
106
          - input_select.aircon_mode
107
          - input_select.aircon_temp_heat
108
          - input_select.aircon_temp_cool
109
          - input_select.aircon_speed
110
        value_template: >
111
           {% set mode = states('input_select.aircon_mode') | lower%}
112
           {% set tempHeat = states('input_select.aircon_temp_heat')  %}
113
           {% set tempCold = states('input_select.aircon_temp_cool')  %}
114
           {% set speed = states('input_select.aircon_speed') %}
115
116
           {% if mode == 'fan' %} 
117
              script.aircon_m{{mode}}_s{{speed}}
118
           {% elif mode == 'heat' %} 
119
              script.aircon_m{{mode}}_t{{tempHeat}}_s{{speed}}
120
           {% else %}
121
              script.aircon_m{{mode}}_t{{tempCold}}_s{{speed}}
122
           {% endif %}   
123
124
automation:
125
- alias: Change Aircon Setting
126
  trigger:
127
    - platform: state
128
      entity_id: input_boolean.aircon_change_settings
129
      to: 'on'
130
  action: 
131
    - service: script.turn_on
132
      data_template:
133
        entity_id: "{{states.sensor.aircon_settings.state}}"
134
    - service: input_boolean.turn_off
135
      entity_id: input_boolean.aircon_change_settings
136
137
switch:
138
      aircon:
139
        friendly_name: Air Conditioner Switch
140
        value_template: "{{ is_state('sensor.aircon', 'on') }}"
141
        turn_on:
142
          - service: input_boolean.turn_on
143
            entity_id: input_boolean.aircon_change_settings
144
        turn_off:
145
          - service: script.aircon_off
146
        icon_template: >
147
                {% set mode = states.input_select.aircon_mode.state %}
148
                {% if mode == 'Fan' %} 
149
                   mdi:weather-windy
150
                {% elif mode == 'Cool' %} 
151
                  mdi:snowflake
152
                {% elif mode == 'Heat' %}
153
                   mdi:white-balance-sunny
154
                {% else %}
155
                   mdi:fan-off
156
                {% endif %}