Mbus integration?

Hello!
I´m thinking of integrating my home power mbus meter into HA and i´m trying to figure out the best way of doing this, i have come up with 2 possible ways and i would like some input

Number one:
Mbus slave -> Mbus master with intregrated modbus converter.
After a quick google search on “modbus home assistant” there seems to be a pretty thought out module for this, suprisingly since modbus is mostly used with industry and building management automation.
Can this work? Will the HA modbus module work with the HA utility meter module? Will the modbus service pop up in HA as a entity and work like any other entity?

Number two:
There are various raspberry pi mbus cards but the integration seems very dificult, haven´t found any working solution for HA on google, anyone here tried this?

The only usb solution i can find is some mbus master for troubleshooting with windows support.

There seems to exist mbus masters with zigbee built in but it lacks alot of information.

Anyone tried any of this or have another solution?

Hi, I’m using an usb-rs485 adapter with my raspberry pi and seems working fine (you can find the cheaper one on AliExpress or similar store) My raspberry pi running the hass.io image and detect directly the usb adapter. You can have some issue with particular modbus device. For example the eastron power meter quite often doesn’t reply to the request

That solution would be the cheapest and probobly the easiest, what usb mbus device do you have?

And by “modbus device” you probobly mean mbus device?

I have this one:


But I have done a mistake reading your post. I understood modbus instead of mbus and this is another protocol

Yes this usb stick seems to be for modbus rtu.

My electricity meter turned out to be modbus upon further inspection :slight_smile: , i bought the same adapter that you have and i can poll the adresses with modpoll successfully, but i can’t get the HA modbus module right.

./modpoll -b 9600 -p none -m rtu -a 66 -t 3:int -r 53 -d 8 -s 1 -c 1 /dev/ttyUSB0
no parity
input reg
32bit int
8databits
1 stopbit
that one gives me a correct reading

But i can’t translate that to HA modbus module
This is what i got and it gives me false reading

modbus:
name: hub1
type: serial
method: rtu
port: /dev/ttyUSB0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N

sensor:

  • platform: modbus
    scan_interval: 60
    registers:
    • name: Total
      hub: hub1
      slave: 66
      register: 353
      register_type: input
      unit_of_measurement: kwh
      count: 1
      scale: 1
      precision: 1
      data_type: int

Any hints?

Doesn’t work with reg “53” either, and 16 or 32 bit shouldn’t matter.

Could you share the datasheet with the modbus map of your meter?

http://www.support-carlogavazzi.se/artikel.asp?ID=2119

theres the modbus registry

im polling adress 41 and 53 input x3 and i get correct value with modpoll, with ha modbus module i get 0.

https://pastebin.com/SqWwq2Y7

debug from modbus_component

in my opinion you have few error in your code.
I’ll suggest to have a look of this site, there are explanation about modbus in general SimplyModbus
then in order to read the address 300053 (kWh (+) TOT
try this configuration:

modbus:
name: hub1
type: serial
method: rtu
port: /dev/ttyUSB0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N

sensor:

platform: modbus
scan_interval: 60
registers:
    name: Total
    hub: hub1
    slave: 66
    register: 53 # input register group (30000) is defined below, here you can write only the last digits 
    register_type: input #should work also reading holding register
    unit_of_measurement: kwh
    count: 2 # we must read 2 register
    scale: 1
    precision: 1
    data_type: float #  If float selected, value will be converted to IEEE 754 floating point format

then below you can see my code as example

#Modbus configuration
modbus:

  • name: Com0
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: N
    timeout: 1

  • name: Com1
    type: serial
    method: rtu
    port: /dev/ttyUSB1
    baudrate: 19200
    stopbits: 1
    bytesize: 8
    parity: E
    timeout: 1

Sensors

sensor:

Weather prediction

  • platform: yr

sensor eastron:

  • platform: modbus
    scan_interval: 3
    registers:
    • name: Voltage
      hub: Com0
      unit_of_measurement: V
      register: 0
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    • name: Current
      hub: Com0
      unit_of_measurement: A
      register: 6
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    • name: ActivePower
      hub: Com0
      unit_of_measurement: W
      register: 12
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

    • name: Frequency
      hub: Com0
      unit_of_measurement: Hz
      register: 70
      register_type: input
      count: 2
      slave: 1
      precision: 2
      data_type: float

sensor nilan:

  • platform: modbus
    scan_interval: 3
    registers:
    • name: T0Controller
      hub: Com1
      register: 200
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T1Intake
      hub: Com1
      register: 201
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T2Inlet
      hub: Com1
      register: 202
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T3Exhaust
      hub: Com1
      register: 203
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T4Outlet
      hub: Com1
      register: 204
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T5Cond
      hub: Com1
      register: 205
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T6Evap
      hub: Com1
      register: 206
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T7Inlet
      hub: Com1
      register: 207
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T8Outdoor
      hub: Com1
      register: 208
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T9Heater
      hub: Com1
      register: 209
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: T10Extern
      hub: Com1
      register: 210
      register_type: input
      count: 1
      slave: 4
      scale: 0.01

    • name: CtrlOn
      hub: Com1
      register: 1000
      register_type: input
      count: 1
      slave: 4

    • name: CtrlMode
      hub: Com1
      register: 1001
      register_type: input
      count: 1
      slave: 4

sensor hvac:

  • platform: modbus
    scan_interval: 3
    registers:
    • name: ACUnitOnOff
      hub: Com0
      register: 0
      register_type: holding
      count: 1
      slave: 2

    • name: ACUnitMode
      hub: Com0
      register: 1
      register_type: holding
      count: 1
      slave: 2

    • name: ACFanSpeed
      hub: Com0
      register: 2
      register_type: holding
      count: 1
      slave: 2

    • name: ACUnitTempSetpoint
      hub: Com0
      register: 4
      register_type: holding
      count: 1
      slave: 2

    • name: ACUnitTempReference
      hub: Com0
      register: 5
      register_type: holding
      count: 1
      slave: 2

    • name: ACUnitExtTempReference
      hub: Com0
      register: 22
      register_type: holding
      count: 1
      slave: 2

    • name: ACIndoorUnitType
      hub: Com0
      register: 4450
      register_type: holding
      count: 1
      slave: 2

    • name: ACTemperatureOutdoor
      hub: Com0
      register: 4413
      register_type: holding
      count: 1
      slave: 2

switch:

  • platform: modbus
    registers:
    • name: OnOffACcmd
      hub: Com0
      slave: 2
      register: 0
      command_on: 1
      command_off: 0
      register_type: holding

I still get value “0”, i’m expecting some number, anything, but its just “0”. I wonder if it’s the module itself, the debug log says:

[homeassistant.util.json] JSON file not found: /srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/modbus/.translations/sensor.en.json

but i can’t find any information about that error on google, any ides?

Maybe something about python version if think 3.5 must be updated (3.7 I think), but I’m not expert about this matter, I’m using hassio on raspberry and all updates are done in automatic
In the release below they mention that python 3.5 is not supported anymore

After changing to 2 count i get some values atleast, but they are off by some.

Settings with modpoll wich gives me the correct values
Protocol configuration: Modbus RTU
Slave configuration…: address = 66, start reference = 41, count = 1
Communication…: /dev/ttyUSB0, 9600, databits 8,stopbits 1, parity none, t/o 1.00 s, poll rate 1000 ms
Data type…: 16-bit register, input register table

I’m staring myself blind comparing the ha modbus module and modpoll :stuck_out_tongue:

Try to set address 40 Instead of 41, some system starting addressing from 0 instead of 1

Yeah tried that.
It’s definetly the right registry because it changes when i turn on the microwave (its current power output in kw)

So is it working now?
Another test is to try to use holding instead of input

No the value is offset.
I think i figured out what the problem is though.

if i change count to 2 in modpoll i get the same value as HA, but if i set count to 1 in HA i get value 0, if i set count to 1 in modpoll, i get the correct value.

Strange… According modbus map should be floating point format
Did you put count 2 and data type float?
I don’t know how is working modpoll

If i change to float i get value 0
Holding doesnt make any difference.