Modbus TCP Dimmer

@Heine_Madsen It lookls like you have configured a sensor as a switch possibly?

Could you post your modbus config for this device please?

Hi,

This is from my configuration.yaml. The last one is my dimmer (Register 1129).

# Smarthouse Modbus
modbus:
  name: SmartHouse
  type: tcp
  host: 192.168.50.2
  port: 502

# SmartHouse Functions
switch:
  platform: modbus
  scan_interval: 10
  registers:
    - name: lys loft multirum
      hub: SmartHouse
      slave: 1
      register: 119
      command_on: 1
      command_off: 0
    - name: loft bryggers
      hub: SmartHouse
      slave: 1
      register: 143
      command_on: 1
      command_off: 0
    - name: stikk TV i walk-in
      hub: SmartHouse
      slave: 1
      register: 155
      command_on: 1
      command_off: 0
    - name: loft stue TV
      hub: SmartHouse
      slave: 1
      register: 167
      command_on: 1
      command_off: 0
    - name: loft viktorialerum
      hub: SmartHouse
      slave: 1
      register: 179
      command_on: 1
      command_off: 0
    - name: Udvendigt - Lys
      hub: SmartHouse
      slave: 1
      register: 191
      command_on: 1
      command_off: 0
    - name: loft stue
      hub: SmartHouse
      slave: 1
      register: 203
      command_on: 1
      command_off: 0
    - name: loft sove værelse
      hub: SmartHouse
      slave: 1
      register: 227
      command_on: 1
      command_off: 0
    - name: loft kontor
      hub: SmartHouse
      slave: 1
      register: 251
      command_on: 1
      command_off: 0
    - name: loft gang lille wc
      hub: SmartHouse
      slave: 1
      register: 263
      command_on: 1
      command_off: 0
    - name: loft entre
      hub: SmartHouse
      slave: 1
      register: 299
      command_on: 1
      command_off: 0
    - name: stikk køkkenbord
      hub: SmartHouse
      slave: 1
      register: 311
      command_on: 1
      command_off: 0
    - name: spot køkkenbord
      hub: SmartHouse
      slave: 1
      register: 323
      command_on: 1
      command_off: 0
    - name: stikk Sofia
      hub: SmartHouse
      slave: 1
      register: 335
      command_on: 1
      command_off: 0
    - name: loft over køkken bord
      hub: SmartHouse
      slave: 1
      register: 347
      command_on: 1
      command_off: 0
    - name: loft Anton
      hub: SmartHouse
      slave: 1
      register: 359
      command_on: 1
      command_off: 0
    - name: loft Sofia
      hub: SmartHouse
      slave: 1
      register: 371
      command_on: 1
      command_off: 0
    - name: stikk multirum
      hub: SmartHouse
      slave: 1
      register: 383
      command_on: 1
      command_off: 0
    - name: loft Mille
      hub: SmartHouse
      slave: 1
      register: 395
      command_on: 1
      command_off: 0
    - name: loft allrum
      hub: SmartHouse
      slave: 1
      register: 407
      command_on: 1
      command_off: 0
    - name: spot terrasse
      hub: SmartHouse
      slave: 1
      register: 419
      command_on: 1
      command_off: 0
    - name: stikk stue
      hub: SmartHouse
      slave: 1
      register: 431
      command_on: 1
      command_off: 0
    - name: spot  spise ø
      hub: SmartHouse
      slave: 1
      register: 443
      command_on: 1
      command_off: 0
    - name: Stikk Mille
      hub: SmartHouse
      slave: 1
      register: 455
      command_on: 1
      command_off: 0
    - name: Stikk Anton
      hub: SmartHouse
      slave: 1
      register: 467
      command_on: 1
      command_off: 0
    - name: Stikk soveværelse
      hub: SmartHouse
      slave: 1
      register: 479
      command_on: 1
      command_off: 0
    - name: Bad stort
      hub: SmartHouse
      slave: 1
      register: 696
      command_on: 1
      command_off: 0
    - name: Bad lille
      hub: SmartHouse
      slave: 1
      register: 734
      command_on: 1
      command_off: 0
    - name: walk in - Loft
      hub: SmartHouse
      slave: 1
      register: 810
      command_on: 1
      command_off: 0
    - name: Carport
      hub: SmartHouse
      slave: 1
      register: 772
      command_on: 1
      command_off: 0
    - name: Kontor spot skrivebord
      hub: SmartHouse
      slave: 1
      register: 965
      command_on: 1
      command_off: 0
    - name: Kontor hems lampested
      hub: SmartHouse
      slave: 1
      register: 991
      command_on: 1
      command_off: 0
    - name: Kontor hems
      hub: SmartHouse
      slave: 1
      register: 1017
      command_on: 1
      command_off: 0
    - name: Kontor hems spot
      hub: SmartHouse
      slave: 1
      register: 1043
      command_on: 1
      command_off: 0
    - name: Stue - Spots
      hub: SmartHouse
      slave: 1
      register: 1129
      command_on: 1
      command_off: 0
      state_on: 0

# SmartHouse Convert to light
light:
  - platform: switch
    name: Loft multirum
    entity_id: switch.lys_loft_multirum
  - platform: switch
    name: Loft bryggers
    entity_id: switch.loft_bryggers
  - platform: switch
    name: Loft TV
    entity_id: switch.loft_stue_TV
  - platform: switch
    name: Loft Viktoalierum
    entity_id: switch.loft_viktorialerum
  - platform: switch
    name: Udendørs lys
    entity_id: switch.Udvendigt_Lys
  - platform: switch
    name: Loft stue
    entity_id: switch.loft_stue
  - platform: switch
    name: Loft soveværelse
    entity_id: switch.loft_sove_vaerelse
  - platform: switch
    name: Loft kontor
    entity_id: switch.loft_kontor
  - platform: switch
    name: Loft lille gang
    entity_id: switch.loft_gang_lille_wc
  - platform: switch
    name: Loft entre
    entity_id: switch.loft_entre
  - platform: switch
    name: Spots køkkenbord
    entity_id: switch.spot_kokkenbord
  - platform: switch
    name: Loft Anton
    entity_id: switch.loft_Anton
  - platform: switch
    name: Loft Sofia
    entity_id: switch.loft_Sofia
  - platform: switch
    name: Loft Mille
    entity_id: switch.loft_Mille
  - platform: switch
    name: Loft alrum
    entity_id: switch.loft_allrum
  - platform: switch
    name: Spots terrasse
    entity_id: switch.spot_terrasse
  - platform: switch
    name: Spots køkken-ø
    entity_id: switch.spot_spise_o
  - platform: switch
    name: Spots stort badeværelse
    entity_id: switch.Bad_stort
  - platform: switch
    name: Spots lille badeværelse
    entity_id: switch.Bad_lille
  - platform: switch
    name: Loft Walk-In
    entity_id: switch.walk_in_Loft
  - platform: switch
    name: Spots carport
    entity_id: switch.Carport
  - platform: switch
    name: Spots skrivebord
    entity_id: switch.Kontor_spot_skrivebord
  - platform: switch
    name: Loft hems
    entity_id: switch.Kontor_hems
  - platform: switch
    name: Spots kontor
    entity_id: switch.Kontor_hems_spot
  - platform: switch
    name: Spots stue
    entity_id: switch.Stue_Spots

@Heine_Madsen quick reply…cheers!

    - name: Stue - Spots
      hub: SmartHouse
      slave: 1
      register: 1129
      command_on: 1
      command_off: 0
      state_on: 0

Not that I can confirm myself as I don’t have any modbus dimmers to test.

BUT…state_on: 0 is a problem I believe

If as you say it is returning

Then that indicates to me this register should be addressed as a sensor. You also should be able to write to it as well (to set the dimmer value)

Also from the Modbus Switch docs…

state_on

(integer)(Optional)

Register value when switch is on.

Default value:

same as command_on

I believe you may need to rectify that?

My bad… state_on was a leftover from some testing.
Tried to put an expression there like “>0” to indicate that any value above 0 is on.

Will try to look into the sensor thing

A dimmer should consist of a switch and a sensor it seems to me?

Switch = on or off
Sensor = dimmer value

Again I have nothing to test so I could be wrong.

@wellsy thaks alot for the input…
Now i can read the correct value by a sensor.
Just have to figure out how to create a light with dimmer in lovelace and the… any hint’s and tips? :slight_smile:
image

Excellent!
@Heine_Madsen Now…You need to setup writing to the sensor/modbus register.

That involves two new config items:

An input_number to choose a value to be set


input_number:
  slider2:
    name: Sludge Pump Restart Delay
    initial: 30
    min: 20
    max: 60
    step: 1

and then an automation to write your modbus register


- id: SludgePumpRestartDelay
  alias: Sludge Pump Restart Delay
  trigger:
    platform: state
    entity_id: input_number.slider2
  action:
    service: modbus.write_register
    data_template:
      hub: hub1
      unit: 1
      address: 3092
      value: "{{ states.input_number.slider2.state|int }}"

EDIT: Then put the switch the sensor and the input number all on a lovelace card

Hi again…

Just need some clarification on the lovelace thing.

i need to define it as a normal modbus switch and a modbus sensor and a input_number?
how would i add it to lovelace card? as a light? or which card type?

I somehow managed to get it on to lovelace now…
but i have one issue… it shows as if it’s off :frowning:
image

Any hints and tips?

Configuration.yaml

# Smarthouse Modbus
modbus:
  name: SmartHouse
  type: tcp
  host: 192.168.50.2
  port: 502

# SmartHouse Functions
switch:
  platform: modbus
  scan_interval: 10
  registers:
    - name: lys loft multirum
      hub: SmartHouse
      slave: 1
      register: 119
      command_on: 1
      command_off: 0
...............
    - name: Stue - Spots
      hub: SmartHouse
      slave: 1
      register: 1129
      command_on: 1
      command_off: 0
sensor:
  platform: modbus
  registers:
    - name: Stue - Spots - Sensor
      hub: SmartHouse
      slave: 1
      register: 1129
input_number:
  slider2:
    name: Dimmer value
    initial: 10
    min: 10
    max: 100
    step: 1

automation.yaml

- id: SpotDimmerStue
  alias: Spots stue
  trigger:
    platform: state
    entity_id: input_number.slider2
  action:
    service: modbus.write_register
    data_template:
      hub: SmartHouse
      unit: 1
      address: 1129
      value: "{{ states.input_number.slider2.state|int }}"

@Heine_Madsen FIRST your config looks to be good… fyi “slider2” is just my name for that input_number…you can call that what you want but must adjust accordingly here as well:

value: "{{ states.input_number.slider2.state|int }}"

Next is the dimmer working atm? IE: you can change the brightness?

The switch advice I gave may be wrong? Maybe you just set the dimmer value to ‘0’ OR is there another register or a “coil” which is the switch for the dimmer?

Do you have a manual or other documentation to refer to or do they have tech help/support?

PS: I just use an entity card in lovelace:

      - type: entities
        title: Power
        show_header_toggle: false 
        entities:
          - entity: sensor.import_power
            name: Import kWh
          - entity: input_number.slider16
            name: Set kWh
          - entity: sensor.export_power
            name: Export kWh
          - entity: input_number.slider15
            name: Set kWh
          - entity: sensor.hot_water_power
            name: Hot Water kWh
          - entity: input_number.slider17
            name: Set kWh

Hi @Heine_Madsen, I’m like you have a Hassio --> Carlo Gavazzi Smarthouse (SH2WEB24) Set up in my house. I have not been able to find any information about how to connect the SH2WEB24 with Hassio and it seems there in’t much about it on the web.

Is there any chance you can help me in the right direction how you configure HAssio and SH2WEB24 to communicate?

Best regards M

Hi…

Sorry for late reply…
Did you manage to get thing working? If not, then let me know and i will try to assist.

/Heine

Hi again, Sorry for late replay from me to. No I have not mange to get things to work. I know how to set the SH2WEB24 as slave but don’t know how to retrieve info about things called coils and register.

So aim stuck :slight_smile:

@Heine_Madsen hi!

I have the same carlo gavazzi controller for my smarthome but I have not managed to integrate with hassio… I have however managed to build a python/modbuslib script to read and control lights based on function 1 and 5 accordingly.

I tried to follow your setup to move everything to hassio but I cannot understand where to find the registers that you used (ie. 119, 143 etc). Based on my setup (and smarthome configurator help file), function 5 used input coils with addresses 5376-5503.

More specifically in my setup, I have for instance the “Living room Spots” which I call function 1 to register address (dec) 1333 to read (dupline address G6),and function 5 with register address (dec) 5442 (dupline address I3) to toggle.

Can you please let me know how to find these (working) registers in my setup or how to convert the function 5 register address to hassio?

Any other help would be greatly appreciated, I really need to move the python/modbuslib setup to hassio…

Thank you!
George

One question here, my configuration is following:

modbus:
  name: wago
  type: udp
  host: 192.168.1.2
  port: 502

sensor:
    registers:
    - name: light
      hub: wago
      slave: 1
      register: 12310
      register_type: holding
      count: 1
      scale: 1
      offset: 0
      precision: 0
      data_type: int

input_number:
  target_temp:
    name: Target Heater Temperature Slider
    min: 0
    max: 3
    step: 1
    unit_of_measurement: bulbs
    icon: mdi:target

automation:
  - alias: Send from slider to modbus
    trigger:
      platform: state
      entity_id: input_number.target_temp
    action:
      service: modbus.write_register
      data_template:
        hub: wago
        unit: 1
        address: 12310
        value: "{{ states.input_number.target_temp.state|int }}"
  - alias: Read from modbus to slider
    trigger:
      platform: state
      entity_id: sensor.light
    action:
      service: input_number.set_value
      data:
        value: "{{ states.sensor.light | int }}"

And almost everything works. I can send value to modbus and read it back. sensor.light updates when I change the value on modbus side. I just can’t get to update slider with value I set on modbus side. Any help appreciated.

Hi Guys,

You seem to have quite an experience with the modbus module. Can you perhaps help me with my issue?
https://community.home-assistant.io/t/light-powered-by-modbus-switch/316182

Thank you in advance,
Regards Matt

Hi, Any guys still active here ? I’m going to integrate this, but don’t know where to find the register addresses ? Any hints, maybe, someone who can post working configs on a dimmer configuration ?

And also, it seems like it’s necessary to enable modbus on the controller. Where to do so ? I have access with the programming software already

I can only operate on node-red and convert it to mqtt access home-assistant.