One thing that took me a while to debug: on my system, this whole thing only worked when I put the MAC address in capitals, for some reason when copying it out of my router data it came in with lower case letters. Might want to update the comments at top to make that clear.
This all seems to work with the exception of the swing mode. Iâm getting âunknownâ for the sensor.swing_mode_xxx
Hereâs my yaml for reference:
rest_command:
bed2_aircon_setmode:
url: http://192.168.8.36/SetParam
method: POST
payload: >
{% set aircomodes = {"auto": '"iu_op_mode":"0"',"cool": '"iu_op_mode":"1"',"dry": '"iu_op_mode":"2"',"fan_only": '"iu_op_mode":"3"',"heat": '"iu_op_mode":"4"',"off": '"iu_onoff":"0"'} %}
{% set opmode = aircomodes.get(hvac_mode, 0) %}
{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{ {{opmode}} }}
bed2_aircon_settemp:
url: http://192.168.8.36/SetParam
method: POST
payload: >
{% set setroomtemp = (target_temp | float * 10) | int %}
{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_set_tmp":"{{ setroomtemp }}"}}
bed2_aircon_set_fan_speed:
url: http://192.168.8.36/SetParam
method: POST
payload: >
{% set fanspds = {"auto": 0, "Quiet": 2,"low": 5,"medium": 8,"high": 11} %}
{% set spd = fanspds.get(fan_mode, 0) %}
{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_fan_spd":"{{ spd }}"}}
# enable if your device has a swing mode
bed2_aircon_set_swing_mode:
url: http://192.168.8.36/SetParam
method: POST
payload: >
{% set mode = {"off": 0, "on": 1} %}
{% set swing = mode.get(swing_mode, 0) %}
{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_fan_spd":"{{ swing }}"}}
# not all units especially ducted have powerful mode. Powerful runs for a short period then stops
bed2_aircon_pwrfull_on:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_powerfull":"1"}}'
bed2_aircon_pwrfull_off:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_powerfull":"0"}}'
# these aren't used by the template but included for completion
bed2_aircon_on:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_onoff":"1"}}'
bed2_aircon_off:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_onoff":"0"}}'
bed2_aircon_eco_on:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_economy":"1"}}'
bed2_aircon_eco_off:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_economy":"0"}}'
bed2_aircon_fanctrl_on:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_fan_ctrl":"1"}}'
bed2_aircon_fanctrl_off:
url: http://192.168.8.36/SetParam
method: POST
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"02","value":{"iu_fan_ctrl":"0"}}'
rest:
- resource: http://192.168.8.36/GetParam
scan_interval: 60
payload: '{"device_id":"106838462EC1","device_sub_id":0,"req_id":"","modified_by":"","set_level":"03","list":["iu_set_tmp","iu_indoor_tmp","iu_outdoor_tmp","iu_onoff","iu_economy","iu_fan_ctrl","iu_fan_ctrl","iu_powerful","ou_low_noise","iu_op_mode","iu_fan_spd","iu_af_swg_vrt"]}'
sensor:
- name: "Temp Outside bed2 Aircon"
value_template: "{{ (((value_json['value']['iu_outdoor_tmp'] | float / 100 ) - 32 ) * 5/9) | round(2) }}"
unit_of_measurement: "°C"
- name: "Temp Inside bed2 Aircon"
value_template: "{{ (((value_json['value']['iu_indoor_tmp'] | float / 100 ) - 32 ) * 5/9) | round(2) }}"
unit_of_measurement: "°C"
- name: "Requested Temp bed2 Aircon"
value_template: "{{ (value_json['value']['iu_set_tmp'] | float / 10 )| round(2) }}"
unit_of_measurement: "°C"
- name: "Mode bed2 Aircon"
value_template: >
{% set mapper ={'0': 'auto','1': 'cool','2': 'dry','3': 'fan_only','4': 'heat'} %}
{% set state = value_json['value']['iu_op_mode'] %}
{{ mapper[state] if state in mapper else 'Unknown' }}
- name: "Fan Speed bed2 Aircon"
value_template: >
{% set mapper ={'0': 'auto','2': 'Quiet','5': 'low','8': 'medium','11': 'high'} %}
{% set state = value_json['value']['iu_fan_spd'] %}
{{ mapper[state] if state in mapper else 'Unknown' }}
binary_sensor:
- name: "Power Status bed2 Aircon"
value_template: "{{ (value_json['value']['iu_onoff']) }}"
# enable if your device has a swing mode
- name: "Swing Mode bed2 Aircon"
value_template: >
{% set mapper ={'0': 'off','1': 'on'} %}
{% set state = value_json['value']['iu_af_swg_vrt'] %}
{{ mapper[state] if state in mapper else 'Unknown' }}
climate:
- platform: climate_template
# the name: can have capital letters if desired
name: bed2 Aircon
modes:
- "auto"
- "dry"
- "off"
- "cool"
- "fan_only"
- "heat"
fan_modes:
- "auto"
- "Quiet"
- "low"
- "medium"
- "high"
# enable if your device has a swing mode
swing_modes:
- "on"
- "off"
min_temp: 15
max_temp: 30
current_temperature_template: "{{ states('sensor.temp_inside_bed2_aircon') }}"
hvac_mode_template: >
{% if is_state('binary_sensor.power_status_bed2_aircon', 'off') %}
off
{% else %}
{{ states('sensor.mode_bed2_aircon') }}
{% endif %}
target_temperature_template: "{{ states('sensor.requested_temp_bed2_aircon') }}"
fan_mode_template: "{{ states('sensor.fan_speed_bed2_aircon') }}"
# enable if your device has a swing mode
swing_mode_template: "{{ states('binary_sensor.swing_mode_bed2_aircon') }}"
set_hvac_mode:
- service: rest_command.bed2_aircon_on
- delay: 1
- service: rest_command.bed2_aircon_setmode
data:
hvac_mode: "{{ hvac_mode }}"
- delay: 2
- service: homeassistant.update_entity
entity_id: sensor.mode_bed2_aircon
set_temperature:
- service: rest_command.bed2_aircon_settemp
data:
target_temp: "{{ temperature }}"
- delay: 2
- service: homeassistant.update_entity
entity_id: sensor.requested_temp_bed2_aircon
set_fan_mode:
- service: rest_command.bed2_aircon_set_fan_speed
data:
fan_mode: "{{ fan_mode }}"
- delay: 2
- service: homeassistant.update_entity
entity_id: sensor.fan_speed_bed2_aircon
# enable if your device has a swing mode
set_swing_mode:
- service: rest_command.bed2_aircon_set_swing_mode
data:
swing_mode: "{{ swing_mode }}"
- delay: 2
- service: homeassistant.update_entity
entity_id: binary_sensor.swing_mode_bed2_aircon