Closed martinmalek closed 3 years ago
modbus documentation modbus source (message by IssueLinks)
Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as it has been labeled with an integration (modbus
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
One of your sensors is not a sensor (possibly wrong input_type or it is a binary sensor): ‘’’ homeassistant.components.modbus.modbus] Pymodbus: Nibe: Exception Response(130, 2, IllegalFunction) ‘’’ I do not know modbus_cli so I have no idea how that handles error situations.
you need to isolate the sensors with problems (e.g. adding sensors one by one) and make a log only with the faulty ones (and of course check if they are configured correctly).
I edited my post since I noticed that the modbus-cli example output was not correct due to me including unused registers which it didn't handle and skipped some of the working ones in the output. I removed the registers from the example above for any other readers to not get confused.
@janiversen - Ok. I'll attempt to remove all sensors but one and see if I can land in the correct modbus settings
@janiversen - I can provide some more output on the modbus-cli communication. Perhaps that can be useful to tell what type of settings would make sense in HA modbus?
modbus syntax used is: modbus [IP] [MODBUS_TYPE@]ADDRESS[/BINARY_TYPE]
MODBUS_TYPE code | name | size | writable |
---|---|---|---|
h | holding register | 16 bits | yes |
i | input register | 16 bits | no |
c | coil | 1 bit | yes |
d | discrete input | 1 bit | no |
BINARY_TYPE code | type |
---|---|
h | 16 bits signed integer |
H | 16 bits unsigned integer |
i | 32 bits signed integer |
I | 32 bits unsigned integer |
f | 32 bits IEEE 754 float |
According to Nibe docs (https://proffs.nibe.se/upload/NEW/Support/Kommunikation/M12676SV.pdf) the majority of registers are FC04, Input, int16 but maybe you can see if there is anything in the packing or endianess going on?
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1/h -v
Parsed 0 registers definitions from 1 files
→ < 9d 53 00 00 00 06 ff 04 00 01 00 01 >
← < 9d 53 00 00 00 05 ff 04 02 00 38 > 11 bytes
← [56]
1: 56 0x38
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@5/h -v
Parsed 0 registers definitions from 1 files
→ < 26 ee 00 00 00 06 ff 04 00 05 00 01 >
← < 26 ee 00 00 00 05 ff 04 02 01 57 > 11 bytes
← [343]
5: 343 0x157
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@7/h -v
Parsed 0 registers definitions from 1 files
→ < ee 72 00 00 00 06 ff 04 00 07 00 01 >
← < ee 72 00 00 00 05 ff 04 02 01 3c > 11 bytes
← [316]
7: 316 0x13c
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@9/h -v
Parsed 0 registers definitions from 1 files
→ < c1 fc 00 00 00 06 ff 04 00 09 00 01 >
← < c1 fc 00 00 00 05 ff 04 02 01 bb > 11 bytes
← [443]
9: 443 0x1bb
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@10/h -v
Parsed 0 registers definitions from 1 files
→ < 0b b4 00 00 00 06 ff 04 00 0a 00 01 >
← < 0b b4 00 00 00 05 ff 04 02 00 32 > 11 bytes
← [50]
10: 50 0x32
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@11/h -v
Parsed 0 registers definitions from 1 files
→ < be ac 00 00 00 06 ff 04 00 0b 00 01 >
← < be ac 00 00 00 05 ff 04 02 00 15 > 11 bytes
← [21]
11: 21 0x15
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@12/h -v
Parsed 0 registers definitions from 1 files
→ < 28 25 00 00 00 06 ff 04 00 0c 00 01 >
← < 28 25 00 00 00 05 ff 04 02 01 59 > 11 bytes
← [345]
12: 345 0x159
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@13/h -v
Parsed 0 registers definitions from 1 files
→ < c5 0d 00 00 00 06 ff 04 00 0d 00 01 >
← < c5 0d 00 00 00 05 ff 04 02 02 65 > 11 bytes
← [613]
13: 613 0x265
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@14/h -v
Parsed 0 registers definitions from 1 files
→ < b8 55 00 00 00 06 ff 04 00 0e 00 01 >
← < b8 55 00 00 00 05 ff 04 02 01 39 > 11 bytes
← [313]
14: 313 0x139
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@16/h -v
Parsed 0 registers definitions from 1 files
→ < 45 24 00 00 00 06 ff 04 00 10 00 01 >
← < 45 24 00 00 00 05 ff 04 02 00 53 > 11 bytes
← [83]
16: 83 0x53
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@26/h -v
Parsed 0 registers definitions from 1 files
→ < ed 4f 00 00 00 06 ff 04 00 1a 00 01 >
← < ed 4f 00 00 00 05 ff 04 02 00 e5 > 11 bytes
← [229]
26: 229 0xe5
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@86/h -v
Parsed 0 registers definitions from 1 files
→ < ae cc 00 00 00 06 ff 04 00 56 00 01 >
← < ae cc 00 00 00 05 ff 04 02 80 00 > 11 bytes
← [32768]
86: -32768 -0x8000
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1102/h -v
Parsed 0 registers definitions from 1 files
→ < 28 5c 00 00 00 06 ff 04 04 4e 00 01 >
← < 28 5c 00 00 00 05 ff 04 02 00 64 > 11 bytes
← [100]
1102: 100 0x64
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@853/h -v
Parsed 0 registers definitions from 1 files
→ < 0d d6 00 00 00 06 ff 04 03 55 00 01 >
← < 0d d6 00 00 00 05 ff 04 02 00 00 > 11 bytes
← [0]
853: 0 0x0
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@218/h -v
Parsed 0 registers definitions from 1 files
→ < f3 24 00 00 00 06 ff 04 00 da 00 01 >
← < f3 24 00 00 00 05 ff 04 02 00 00 > 11 bytes
← [0]
218: 0 0x0
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1046/h -v
Parsed 0 registers definitions from 1 files
→ < 89 2c 00 00 00 06 ff 04 04 16 00 01 >
← < 89 2c 00 00 00 05 ff 04 02 00 c8 > 11 bytes
← [200]
1046: 200 0xc8
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1083/h -v
Parsed 0 registers definitions from 1 files
→ < 3b 6b 00 00 00 06 ff 04 04 3b 00 01 >
← < 3b 6b 00 00 00 05 ff 04 02 01 ed > 11 bytes
← [493]
1083: 493 0x1ed
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1100/h -v
Parsed 0 registers definitions from 1 files
→ < ce 47 00 00 00 06 ff 04 04 4c 00 01 >
← < ce 47 00 00 00 05 ff 04 02 00 01 > 11 bytes
← [1]
1100: 1 0x1
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@1104/h -v
Parsed 0 registers definitions from 1 files
→ < 12 73 00 00 00 06 ff 04 04 50 00 01 >
← < 12 73 00 00 00 05 ff 04 02 00 20 > 11 bytes
← [32]
1104: 32 0x20
(.env) pi@raspberrypi:~ $ modbus 192.168.x.y i@222/h -v
Parsed 0 registers definitions from 1 files
→ < 8b a1 00 00 00 06 ff 04 00 de 00 01 >
← < 8b a1 00 00 00 05 ff 04 02 00 00 > 11 bytes
← [0]
222: 0 0x0
More info about modbus_cli is not really helpful, because it surely works differently. pymodbus which we use also have a command line interface (REPL), that would help.
but you need to isolate the sensors with a problem.
E.g. the one I mentioned is: name: "Nibe - Driftläge värmebärarpump" address 0x03 0x53 = 853 and quite possibly that is input_type: coil
you cannot expect me to run through all your sensors….once you have a log with the faulty sensors (and you e.g, have tried different input types) then I can start looking if there is a software problem.
Don't worry, I wasn't expecting that you would go through all the sensors. I'm simply trying to provide input as possible for transparency. 😄
Thanks for the pymodbus cli REPL. I can give that a go and see if I can log anything more useful from that.
The reason I thought 853 could have been a binary sensor is because the docs mention it's a on/off indicator using a u8.
Funktion | ID | Registertyp | Storlek | Enhet | Faktor | Läge | Status |
---|---|---|---|---|---|---|---|
Driftläge värmebärarpump | 853 | FC04 Input Register | s8 | - | 1 | R | 0 - auto or 1 - manuellt |
I managed to get it working. Here is how I did it if anyone wants to know for the future.
Using pymodbus repl according to https://pymodbus.readthedocs.io/en/latest/source/library/REPL.html
Installing pymodbus repl
python3 -m venv .env
source .env/bin/activate
pip install pymodbus[repl] --upgrade
repl console
pymodbus.console
pymodbus.console tcp --host 192.168.x.y --port 502
client.connect
Calling input registers
client.read_input_registers address 1 count 1 unit 1
client.read_input_registers address 5 count 1 unit 1
client.read_input_registers address 7 count 1 unit 1
client.read_input_registers address 9 count 1 unit 1
client.read_input_registers address 10 count 1 unit 1
client.read_input_registers address 11 count 1 unit 1
client.read_input_registers address 12 count 1 unit 1
client.read_input_registers address 13 count 1 unit 1
client.read_input_registers address 14 count 1 unit 1
client.read_input_registers address 16 count 1 unit 1
client.read_input_registers address 26 count 1 unit 1
client.read_input_registers address 86 count 1 unit 1
client.read_input_registers address 1102 count 1 unit 1
client.read_input_registers address 853 count 1 unit 1
client.read_input_registers address 218 count 1 unit 1
client.read_input_registers address 1046 count 1 unit 1
client.read_input_registers address 1083 count 1 unit 1
client.read_input_registers address 1100 count 1 unit 1
client.read_input_registers address 1104 count 1 unit 1
client.read_input_registers address 222 count 1 unit 1
Obviously now but I was missing the correct unit / slave in my config before. Setting slave: 1
fixed things.
Final configuration for Nibe S1255 over tcp modbus looks like
modbus:
type: tcp
host: 192.168.x.y
port: 502
name: "Nibe"
delay: 10
#close_comm_on_error: true
retry_on_empty: true
retries: 3
timeout: 15
message_wait_milliseconds: 500
sensors:
- name: "Nibe - Utetemperatur (BT1)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 1
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Framledningstemperatur (BT2)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 5
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Returledningstemperatur (BT3)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 7
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
#- name: "Nibe - Varmvatten topp (BT7)"
# unit_of_measurement: "°C"
# data_type: int16
# device_class: temperature
# address: 8
# input_type: input
# scale: 0.1
# precision: 1
# state_class: measurement
# slave: 1
- name: "Nibe - Varmvatten laddning (BT6)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 9
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Köldbärare in (BT10)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 10
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Köldbärare ut (BT11)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 11
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Kondensor fram (BT12)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 12
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Hetgas (BT14)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 13
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Vätskeledning (BT15)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 14
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Suggas (BT17)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 16
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Rumstemperatur 1 (BT50)"
unit_of_measurement: "°C"
data_type: int16
device_class: temperature
address: 26
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
#- name: "Nibe - Extern Framledning (BT25)"
# unit_of_measurement: "°C"
# data_type: int16
# device_class: temperature
# address: 39
# input_type: input
# scale: 0.1
# precision: 1
# state_class: measurement
# slave: 1
- name: "Nibe - Kompressorgivare (EB100-BT29)"
unit_of_measurement: "°C"
data_type: int16
address: 86
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Värmebärarpumphastighet (GP1)"
unit_of_measurement: "%"
data_type: int16
device_class: temperature
address: 1102
input_type: input
scale: 0.1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Värmebärarpumphastighet Manuell (GP1)"
unit_of_measurement: "%"
data_type: int16
device_class: power_factor
address: 218
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Aktuell kompressorfrekvens"
unit_of_measurement: "Hz"
data_type: int16
address: 1046
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Kompressorstarter"
unit_of_measurement: None
data_type: int16
address: 1083
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Köldbärarpumphastighet (GP2)"
unit_of_measurement: "%"
data_type: int16
device_class: power_factor
address: 1104
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Köldbärarpumphastighet Manuell (GP2)"
unit_of_measurement: "%"
data_type: int16
device_class: power_factor
address: 222
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Driftläge värmebärarpump"
unit_of_measurement: None
data_type: int16
address: 853
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
- name: "Nibe - Kompressor status"
unit_of_measurement: None
data_type: int16
address: 1100
input_type: input
scale: 1
precision: 1
state_class: measurement
slave: 1
#- name: "Nibe - Kompressor status"
# unit_of_measurement: None
# data_type: int16
# address: 1319
# input_type: input
# scale: 1
# precision: 1
# state_class: measurement
# slave: 1
The problem
Trying to get modbus working with Nibe S1255 but I'm getting some errors and empty answers. Please see more details further down
What is version of Home Assistant Core has the issue?
2021.9.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Modbus
Link to integration documentation on our website
https://www.home-assistant.io/integrations/modbus/
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
Here is how I checked if the pump responds to modbus using https://github.com/favalex/modbus-cli
Installing modbus-cli
Getting modbus addresses from https://proffs.nibe.se/upload/NEW/Support/Kommunikation/M12676SV.pdf
Note that for me the following addresses are not included since they’re not working, probably due to the features missing or not being used 8, 39, 1319.
Calling pump using modbus-cli with the addresses above
It's possible to query all registers in one go using a input file
Using the file above
Note that for me the following addresses are not working, probably due to the features missing or not being used: 8, 39, 1319.
The other registers return just fine as per the output below.