Modbus Integration - add an ability to use different function codes in climate platform

Hi,
Real life example: I have a ventilation unit made by Nilan, very popular brand in Scandinavia. I use Modbus Integration to read sensors and change states on it. However, Modbus implementation in this device allows to write registers with function code 16 (0x10) only, for both single register or an array.

Function code 0x10 for write register can be called by using a configuration variabel write_type: holdings , but only in platforms:

  • switch
  • fan
  • light

Or by using service modbus.write_register with array as value.

There is no option to use function code 0x10 in climate platform.

I think it should be quite straightforward to implement configuration variable write_type: holdings in climate platform, for:

  • target_temp_register
  • hvac_mode_register
  • hvac_onoff_register

since is already implemented in others platroms.

So, configuration could look like this:

modbus:
  - name: hub1
    type: tcp
    host: IP_ADDRESS
    port: 502
    climates:
      - name: "Bedroom Air Condition"
        address: 10
        target_temp_register: 10
        write_type: holdings    # New feature 
        hvac_mode_register:
          address: 11
          write_type: holdings    # New feature 
          values:
            auto: 0
            cool: 1
            heat: 2
            fan_only: 3
            dry: 4
        hvac_onoff_register: 11
          write_type: holdings    # New feature 

I have the exact same issue. Found a workaround ?

I din’t used more time to dig in it. So mine workaround is a bunch of automation, which triggering service modbus.write_register with array as value, when I need to change something. I don’t use climate integration on Modbus right now.

Here is a example of temperature setpoint automation. Its controlled by a helper (input_number).

alias: NILAN - Temp Setpoint
description: Nilan Temperature Setpoint
trigger:
  - platform: state
    entity_id: input_number.nilan_set_point
action:
  - service: modbus.write_register
    data:
      hub: nilanhub
      unit: 30
      address: 1004
      value: "[{{states('input_number.nilan_set_point') | int }}00, 0]"

I think that this topic could be marked as solved.
The feature requested is available using the parameter write_registers as described into the documentation.