Meltem WRG II integration via Meltem Gateway and Modbus

Hi everyone,

I’d like to share my experience integrating my Meltem WRG II units (M-WRG-II E-T-FC) into HA utilizing the Meltem Gateway.

This guide deals specifically with the integration of WRG II devices which are connected to the Meltem Gateway (M-WRG-GW) into Home Assistant. Not any other versions they offer!

Setup

After talking to the Meltem support they told me that their gateway exposes a Modbus COM RTU interface via the Micro-USB interface. There is no need to enable anything. You can also still use their app in parallel in combination with HA if you want or switch completely to HA.

First pair all your WRG devices to the gateway using the official app.If that worked you can continue with the HA integration. Then connect a MicroUSB cable to the gateway and plug it into your computer, RPi or whatever you are running HA on. The gateway is then powered via USB and your HA computer should recognize a new COM interface you can connect to. On my Pi4 with Hass.io it is /dev/ttyACM0. You can also check dmesg output via terminal what got recognized by the kernel.

If that works you must setup the modbus RTU integration according to Modbus - Home Assistant.

My config now looks like this:

- name: modbus_hub
  type: serial
  port: /dev/ttyACM0
  baudrate: 19200
  bytesize: 8
  method: rtu
  parity: E
  stopbits: 1

  sensors:
# Lüftung SZ
    - name: "Lüftung SZ Modus"
      slave: 3
      address: 41100
      data_type: int16   
      scan_interval: 3
    - name: "Lüftung SZ Modus Zuluft"
      slave: 3
      address: 41101
      data_type: int16   
      scan_interval: 3
    - name: "Lüftung SZ Ablufttemperatur"
      slave: 3
      address: 41000   
      data_type: float32
      device_class: temperature
      unit_of_measurement: "°C"      
      scan_interval: 60      
      precision: 1
      swap: word
    - name: "Lüftung SZ Außenlufttemperatur"
      slave: 3
      address: 41002      
      data_type: float32
      device_class: temperature
      unit_of_measurement: "°C"
      precision: 1
      scan_interval: 60      
      swap: word
    - name: "Lüftung SZ Fortlufttemperatur"
      slave: 3
      address: 41004
      data_type: float32
      device_class: temperature
      unit_of_measurement: "°C"      
      scan_interval: 60      
      precision: 1
      swap: word
    - name: "Lüftung SZ Feuchte Abluft"
      slave: 3
      address: 41006
      data_type: int16
      device_class: humidity
      unit_of_measurement: "%"    
      scan_interval: 60      
    - name: "Lüftung SZ CO² Abluft"
      slave: 3
      address: 41007
      data_type: int16
      device_class: carbon_dioxide
      unit_of_measurement: "ppm"      
      scan_interval: 60
    - name: "Lüftung SZ Zulufttemperatur"
      slave: 3
      address: 41009
      data_type: float32
      device_class: temperature
      unit_of_measurement: "°C"      
      scan_interval: 60
      precision: 1
      swap: word
    - name: "Lüftung SZ Feuchte Zuluft"
      slave: 3
      address: 41011
      data_type: int16
      device_class: humidity
      unit_of_measurement: "%"    
      scan_interval: 60      
    - name: "Lüftung SZ Lüfterstufe Abluft"
      slave: 3
      address: 41020      
      data_type: int16
      device_class: volume_flow_rate
      unit_of_measurement: "m³/h"      
      scan_interval: 3
    - name: "Lüftung SZ Lüfterstufe Zuluft"
      slave: 3
      address: 41021   
      data_type: int16
      device_class: volume_flow_rate
      unit_of_measurement: "m³/h"      
      scan_interval: 3
    - name: "Lüftung SZ Zeit bis Filterwechsel"
      slave: 3
      address: 41027
      data_type: int16
      device_class: duration
      unit_of_measurement: "d"      
      scan_interval: 60
    - name: "Modus SZ"
      slave: 3
      address: 41120
      data_type: int16
      #device_class: duration
      #unit_of_measurement: "d"      
      scan_interval: 3600
    - name: "Lüftung SZ Rel. Feuchte Startpunkt"
      slave: 3
      address: 42000
      data_type: int16
      device_class: humidity
      unit_of_measurement: "%"      
      scan_interval: 3

Writing register ^= changing modes, fan speeds etc

To change fan speeds, modes etc. you must basically write 3 register after another. E.g. this script sets the mode to “Auto”

alias: Ventilation - SZ - Auto
sequence:
  - service: modbus.write_register
    metadata: {}
    data:
      hub: modbus_hub
      slave: 3
      address: 41120
      value: 2
  - service: modbus.write_register
    metadata: {}
    data:
      hub: modbus_hub
      slave: 3
      address: 41121
      value: 16
  - service: modbus.write_register
    metadata: {}
    data:
      hub: modbus_hub
      slave: 3
      address: 41132
      value: 0
mode: single

To get the values for the current state and calculate the absolute humidity I’ve created those sensor templates:

    # Schlafzimmer
    luftung_sz_feuchte_zuluft_absolut:
      unit_of_measurement: 'g/m³'
      value_template: >
        {% set h, t = states('sensor.luftung_sz_feuchte_zuluft') | float, states('sensor.luftung_sz_zulufttemperatur') %}
           {% if not h or t == 'unknown' -%}
             'unknown'
           {%- else %}
            {% set t = t | float %}
            {{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(2) }}
           {% endif %}
    luftung_sz_feuchte_abluft_absolut:
      unit_of_measurement: 'g/m³'
      value_template: >
        {% set h, t = states('sensor.luftung_sz_feuchte_abluft') | float, states('sensor.luftung_sz_ablufttemperatur') %}
           {% if not h or t == 'unknown' -%}
             'unknown'
           {%- else %}
            {% set t = t | float %}
            {{ (h*6.112*2.1674*e**((t*17.67)/(t+243.5))/(t+273.15))|round(2) }}
           {% endif %}
    luftung_sz_modus_string:
      value_template: >
            {% if is_state('sensor.luftung_sz_modus', '1')  %}
              Standby
            {% elif is_state('sensor.luftung_sz_modus', '2') and is_state('sensor.luftung_sz_modus_zuluft', '112') %}
              Feuchte-Regelung
            {% elif is_state('sensor.luftung_sz_modus', '2') and is_state('sensor.luftung_sz_modus_zuluft', '176') %}
              CO²-Regelung
            {% elif is_state('sensor.luftung_sz_modus', '2') and is_state('sensor.luftung_sz_modus_zuluft', '48') %}
              Auto
            {% elif is_state('sensor.luftung_sz_modus', '3') and is_state('sensor.luftung_sz_modus_zuluft', '228') %}
              Stufe 1
            {% elif is_state('sensor.luftung_sz_modus', '3') and is_state('sensor.luftung_sz_modus_zuluft', '229') %}
              Stufe 2
            {% elif is_state('sensor.luftung_sz_modus', '3') and is_state('sensor.luftung_sz_modus_zuluft', '230') %}
              Stufe 3
            {% elif is_state('sensor.luftung_sz_modus', '3') %}
              Manuell
            {% elif is_state('sensor.luftung_sz_modus', '4') %}
              Manuell - unbalanciert
            {% endif %}

For all other options please have a look into the documentation of their Modbus versions. See chapter 16 in https://www.meltem.com/fileadmin/user_upload/Downloads_WRG_2/Oeffentliche_Downloads/DE/Betriebsanleitungen/Geraete/Meltem-M-WRG-II-P-E-M-(-F%2C-FC)-Installations-und-Betriebsanleitung.pdf

REMARKS

  • On the Gateway the Modbus register 41000 and 41004 are reversed. That’s why those differ in my config to the documentation. Meltem confirmed this when talking to them that the registers are different here.
  • The first slave ID being used is 2 and then increment in the sequence you’ve added your devices via the app to the gateway.
  • thanks to yoziru for providing this great example for Zehnder systems and some nice graphics I borrowed GitHub - yoziru/esphome-zehnder-comfoair: Interact with Zehnder Comfoair Q using ESPHome and Home Assistant
2 Likes

Sounds great Anton, exactly what i was looking for!
Have some Meltem M-WRG with Gateway here as well.
Any idea how to map the serial connection via Ethernet into the docking container?
NAS is in the ground floor, so not the right place for the Gateway - but i have another NAS that runs Docker in the 2nd floor, possibly there are solutions?
Or - even simpler, is there a way to connect the Gateway also via Ethernet?

I have no idea how to do this unfortunately. But maybe GitHub - custom-components/remote_homeassistant: Links multiple home-assistant instances together would be an option. Never tried it but it sounds promising.

Hi Anton,
Thanks for your example. Based on your work I’am also trying to integrate my Meltem App into HA, but unfortunatly it seems, that my Meltem gateway ist not recognized by my Home Assistant. And I don’t know why. I’ve tried three different USB ports, but non seems to recognize the gateway.
I have tried different commands in the terminal, dmseg and so on, but no USB device… Can you remember, if you have activated anything special?!

Thanks in advance,
Mathias

Hi Mathias,

I first tried it under Windows with GitHub - ClassicDIY/ModbusTool: A modbus master and slave test tool with import and export functionality, supports TCP, UDP and RTU. with no Ethernet connected before I changed to HA. Windows recognized a new device when I connected the gateway via USB. Other than that I did nothing special. It worked out of the box for me.

On my hass.io Pi4 dmesg shows this:

[15415427.135088] usb 1-1.3: new full-speed USB device number 65 using xhci_hcd
[15415427.246378] usb 1-1.3: New USB device found, idVendor=10ac, idProduct=010a, bcdDevice= 1.00
[15415427.246407] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15415427.246413] usb 1-1.3: Product: Modbus
[15415427.246417] usb 1-1.3: Manufacturer: Honeywell
[15415427.246420] usb 1-1.3: SerialNumber: 4807869E0
[15415427.253843] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device

Hi Mathias,

I have the same issue, connected Meltem Gateway to HA Raspi via USB, but device is not recognized. dmesg log shows no related entries.

Did you find a solution in the meantime?