Integrating AC IRremote and Boiler opentherm control in home assistant

Hello everybody!
This is my first post on the forum.
Since a few weeks ago I started using home assistant and bringing improvements to my house.
I ordered a lot of things from China and they started showing up. I added mosquitto broker and zigbee2mqtt to my HA installation, and, with the cc2531 stick and some Ikea and xiaomi zigbee devices, I added lights controls, temperature, humidity and pressure sensors around the house, and some smart switches for appliances. All is working great here, including 2 xiaomi dafang cameras with modded firmwares, and mqtt control.

However, a few days ago I received 3 nodemcu and 2 IR blasters, that I want to use to control my 2 Daikin heatpumps through the IR blasters and Buderus boiler through opentherm. I intend to use these tutorials as starting points, but I am in a pickle.
AC: https://www.sysrun.io/2017/02/22/use-a-esp8266-to-control-your-ac-via-mqtt/
Boiler: http://ihormelnyk.com/mqtt_thermostat

The problem I am having now, is: I followed the tutorial for the Daikin heatpump, installed all the libraries, flashed the nodemcu, it connects to wifi, it replies to ping. I can see the device in MQTT Explorer:

However, nothing is showing up in HA. I thought something will show up in integrations, as the xiaomi cameras did.

Should it pop up by itself, or do I have to start doing something else? Where should I start from?

(Regarding the Boiler board, I still have to get the adapter from work. ATM it is connecting to wifi, but ping reply has a high drop rate, like 66%)
Thanks in advance.

Hello again!
I come back on this issue, as I managed to learn just a little bit more about integrating new things into home assistant/mqtt.
I managed to modify and integrate a mains general power meter (zmai90) and learned how to identify the topic.

Because of this, I read the tutorials again, and I am now in the following situation:
from https://www.sysrun.io/2017/02/22/use-a-esp8266-to-control-your-ac-via-mqtt/ , I know the mqtt status and command channels. These are stat/daikin and cmnd/daikin/#.
extract from the tutorial: " The software is listening for commands on a specific topic configured via the constant MQTT_COMMAND_CHANNEL . The default configuration is “ cmnd/daikin/# “. To set the power on the A/C, you just publish “ 1 ” to the topic “ cmnd/daikin/power “. The MCU will now send the command via IR and post the current values of every setting (power, mode, fan etc.) as JSON to the topic “ stat/daikin ”"

from https://github.com/ToniA/arduino-heatpumpir/blob/4f81e180d35236f6ac979e4cd90e7f90b7c4701f/HeatpumpIR.h , I found the commands that can be sent to the ir blaster nodemcu:
// Power state
#define POWER_OFF 0
#define POWER_ON 1

// Operating modes
#define MODE_AUTO 1
#define MODE_HEAT 2
#define MODE_COOL 3
#define MODE_DRY 4
#define MODE_FAN 5
#define MODE_MAINT 6

// Fan speeds. Note that some heatpumps have less than 5 fan speeds
#define FAN_AUTO 0
#define FAN_1 1
#define FAN_2 2
#define FAN_3 3
#define FAN_4 4
#define FAN_5 5
#define FAN_SILENT 6 //SILENT/NIGHTMODE

// Vertical air directions. Note that these cannot be set on all heat pumps
#define VDIR_AUTO 0
#define VDIR_MANUAL 0
#define VDIR_SWING 1
#define VDIR_UP 2
#define VDIR_MUP 3
#define VDIR_MIDDLE 4
#define VDIR_MDOWN 5
#define VDIR_DOWN 6

// Horizontal air directions. Note that these cannot be set on all heat pumps
#define HDIR_AUTO 0
#define HDIR_MANUAL 0
#define HDIR_SWING 1
#define HDIR_MIDDLE 2
#define HDIR_LEFT 3
#define HDIR_MLEFT 4
#define HDIR_MRIGHT 5
#define HDIR_RIGHT 6

and from https://www.home-assistant.io/integrations/climate.mqtt/ , I found a standard, simple, climate configuration that would be able to control the AC:
climate:

  • platform: mqtt
    name: Study
    modes:
    • “off”
    • “cool”
    • “fan_only”
      swing_modes:
    • “on”
    • “off”
      fan_modes:
    • “high”
    • “medium”
    • “low”
      power_command_topic: “study/ac/power/set”
      mode_command_topic: “study/ac/mode/set”
      temperature_command_topic: “study/ac/temperature/set”
      fan_mode_command_topic: “study/ac/fan/set”
      swing_mode_command_topic: “study/ac/swing/set”
      precision: 1.0

What I do not know, is how to configure the modes so the climate integration sends the necessary data to the required command topic.
Also, I see the nodemcu will post the current status as JSON format, so these will have to be translated in a way?

I know this should not be very complicated, but I am not able to put it all together. Anybody care to help?

Thanks!

Please see the sticky post which includes information on how to use code blocks. Without correct formatting it’s hard to help you.

Hello @Tinkerer.

Thank you for the reply.
So, I have:

  • status channel: stat/daikin

  • command channel: cmnd/daikin/#
    And the necessary commands to send to the command channel:
    |Command|Descr → Value|
    | — | — |
    |cmnd/daikin/power|POWER_OFF → 0
    POWER_ON → 1|
    |cmnd/daikin/mode|MODE_AUTO → 1
    MODE_HEAT → 2
    MODE_COOL → 3
    MODE_DRY → 4
    MODE_FAN → 5|
    |cmnd/daikin/fan|FAN_AUTO → 0
    FAN_1 → 1
    FAN_2 → 2
    FAN_3 → 3
    FAN_4 → 4
    FAN_5 → 5|
    |cmnd/daikin/temp|Numeric value|

    Standard configuration for Climate component:

  - platform: mqtt
    name: Study
    modes:
      - "off"
      - "cool"
      - "fan_only"
    swing_modes:
      - "on"
      - "off"
    fan_modes:
      - "high"
      - "medium"
      - "low"
    power_command_topic: "study/ac/power/set"
    mode_command_topic: "study/ac/mode/set"
    temperature_command_topic: "study/ac/temperature/set"
    fan_mode_command_topic: "study/ac/fan/set"
    swing_mode_command_topic: "study/ac/swing/set"
    precision: 1.0

where I would need to replace:
“study/ac/power/set” with “cmnd/daikin/power”
“study/ac/mode/set” with “cmnd/daikin/mode”
“study/ac/temperature/set” with “cmnd/daikin/temp”
“study/ac/fan/set” with “cmnd/daikin/fan”
“study/ac/swing/set” -> disable, I want it static.

Now, I think the modes, fan_modes, will also need to be changed, but I do not know how to modify those so it will work, and also, report back from nodemcu.

I see that in the mqtt hvac component instructions it is mentioned something about json template, but this is just over my head.

This is why I am asking for help.
Thanks again.

I read the Private Message you sent to me. I appreciate the compliments but please understand that I, like so many others, volunteer our time and choose which topics interest us (and which do not).

You had linked to my participation in this topic:

The solution I had supplied there is the same one you can adopt to control your AC unit. I suggest you begin by copying the suggested climate configuration and replacing its topics with the ones used by your system. Once you have done that, post it here and we can review it together.

You said the AC unit publishes its status as a single JSON payload. Please post an example of it so I can help you create an appropriate template to extract needed data for the climate component.

The commands sent by the climate component are not the commands your AC unit accepts. Therefore we will use automations (like the ones posted in the link) to convert the commands into the appropriate format.

First off, Thank you very much for your interest.

What I configured until now:
configuration.yaml

climate:
  - platform: mqtt
    name: Livingroom
    optimistic: false
    retain: false
    qos: 0
    payload_on: 1
    payload_off: 0
    modes:
      - "off"
      - "auto"
      - "heat"
      - "cool"
      - "dry"
      - "fan_only"
#    swing_modes:
#      - "on"
#      - "off"
    fan_modes:
      - "auto"
      - "low"
      - "medium"
      - "high"
      - "silent"
#    mode_state_topic: "ventilation/control/ModeSet" 
#    mode_state_template: >-
#      {% set modes = { '0':'off', '1':'heat',  '2':'cool', '3':'auto'} %}
#      {{ modes[value] if value in modes.keys() else 'off' }}
    mode_command_topic: "convert/modeset"
#    current_temperature_topic: "temp/T7_Inlet"
#    current_temperature_template: >-
#     {{ value | float | multiply(0.01) | round(1) }}
    min_temp: 16
    max_temp: 28
    temp_step: 1
#    temperature_state_topic: "ventilation/control/TempSet"
#    temperature_state_template: >-
#     {{ value | float | multiply(0.01) | round(1) }}
    temperature_command_topic: "convert/tempset"
    fan_mode_command_topic: "convert/fanset"
#    power_command_topic: "cmnd/daikin/power"
#    swing_mode_command_topic: "study/ac/swing/set"
#    precision: 1.0

Quick question: Can I use any text for fan modes and modes, besides the usual off, auto, heat, cool, low, medium? Because I would like to be able to configure it with more modes.
automations.yaml:

- alias: 'Convert HVAC Mode'
  hide_entity: true
  trigger:
    platform: mqtt
    topic: convert/modeset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/mode"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'off':'0', 'auto':'1', 'heat':'2', 'cool':'3', 'dry':'4', 'fan_only':'5' } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

- alias: 'Convert HVAC Fan Mode'
  hide_entity: true
  trigger:
    platform: mqtt
    topic: convert/fanset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/fan"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'auto':'0', 'low':'2', 'medium':'3', 'high':'5', 'silent':'6' } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

- alias: 'Convert HVAC Temperature'
  hide_entity: true
  trigger:
    platform: mqtt
    topic: convert/tempset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/temp"
      payload: "{{ trigger.payload | float | multiply(1) | round }}"

As you can see, I also added a section for fan modes, and I will try to add one more section for vertical swing options.

When I hit the check configuration button, I get:

So I commented out the optimistic line. I do not know what this does, and I commented out the hide_entity lines in the 3 automations.

This resulted in a valid config. I can send commands to the AC unit. YAY!
What does not work, and I was expecting this, is the power off/on. I suspected this will not work, because this should be sent to another topic, cmnd/daikin/power . I do not know how to do this yet, but I suspect I should add another data_template to the convert/modeset section in automations.

In MQTT explorer I can see the payloads from the nodemcu like this, in history:

Thanks again. At least, now I can set the temperature, fan mode, :slight_smile:

As far as I know, no you cannot. Limit them to the ones shown in the documentation:

modes
(list)(Optional)
A list of supported modes. Needs to be a subset of the default values.
Default value:
[“auto”, “off”, “cool”, “heat”, “dry”, “fan_only”]

The errors that have been reported as due to the fact that things have changed since the original example was posted last fall. Remove the following option from the climate configuration:
optimistic:
Remove the following option from both automations:
hide_entity:

Thanks for the JSON data. I’ll use it to devise templates but you may have wait until I get around to it this evening. Is “temp” the ambient room temperature or the AC unit’s target (setpoint) temperature?

Thank you Taras.

I removed the unnecessary lines.
And I did the following modifications:
config:

climate:
  - platform: mqtt
    name: Livingroom
    retain: false
    qos: 0
    payload_on: 1
    payload_off: 0
    modes:
      - "off"
      - "auto"
      - "heat"
      - "cool"
      - "dry"
      - "fan_only"
    swing_modes:
      - "swing"
      - "up"
      - "mid"
      - "down"
    fan_modes:
      - "auto"
      - "low"
      - "medium"
      - "high"
      - "silent"
#    mode_state_topic: "ventilation/control/ModeSet" 
#    mode_state_template: >-
#      {% set modes = { '0':'off', '1':'heat',  '2':'cool', '3':'auto'} %}
#      {{ modes[value] if value in modes.keys() else 'off' }}
    mode_command_topic: "convert/modeset"
#    current_temperature_topic: "temp/T7_Inlet"
#    current_temperature_template: >-
#     {{ value | float | multiply(0.01) | round(1) }}
    min_temp: 16
    max_temp: 28
    temp_step: 1
#    temperature_state_topic: "ventilation/control/TempSet"
#    temperature_state_template: >-
#     {{ value | float | multiply(0.01) | round(1) }}
    temperature_command_topic: "convert/tempset"
    fan_mode_command_topic: "convert/fanset"
    swing_mode_command_topic: "convert/swingset"
#    power_command_topic: "cmnd/daikin/power"
#    precision: 1.0

I did not alter the modes.
However, fan modes and swing modes can be edited as I like.
automations:

- alias: 'Convert HVAC Mode'
  trigger:
    platform: mqtt
    topic: convert/modeset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/mode"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'auto':'1', 'heat':'2', 'cool':'3', 'dry':'4', 'fan_only':'5' } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

- alias: 'Convert HVAC Power'
  trigger:
    platform: mqtt
    topic: convert/modeset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/power"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'off':'0', 'auto':'1', 'heat':'1', 'cool':'1', 'dry':'1', 'fan_only':'1'  } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

- alias: 'Convert HVAC Fan Mode'
  trigger:
    platform: mqtt
    topic: convert/fanset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/fan"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'auto':'0', 'low':'2', 'medium':'3', 'high':'5', 'silent':'6' } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

- alias: 'Convert HVAC Temperature'
  trigger:
    platform: mqtt
    topic: convert/tempset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/temp"
      payload: "{{ trigger.payload | float | multiply(1) | round }}"

- alias: 'Convert HVAC Swing Mode'
  trigger:
    platform: mqtt
    topic: convert/swingset
  action:
    service: mqtt.publish
    data_template:
      topic: "cmnd/daikin/vswing"
      payload: >-
        {% set mode_name = trigger.payload %}
        {% set modes = { 'swing':'1', 'up':'2', 'mid':'4', 'down':'6' } %}
        {{ modes[mode_name] if mode_name in modes.keys() else '0' }}

for the automations, I added another one for power and set it on when using any of the active modes.
Now I am able to control it!

Do not hurry for the feedback, as this is a months old project. I am integrating all that I can, one at a time.

After my vacation, I will be back an will start investigating the integration of my heating boiler. That will be a little bigger project because I will have to integrate some automatic valves, to control the heating in each room. :slight_smile:

Have a nice day!