Hello to all, I come here to post in the hope someone might assist with my problem.
I have a weird and annoying problem with following number component of the modbus_controller:
number:
- platform: modbus_controller
modbus_controller_id: modbus_dantherm
name: "Set Temperature"
id: temp_set
device_class: temperature
register_type: holding
address: 1017 ## address of the register inside the Modbus slave device
unit_of_measurement: "°C"
value_type: U_WORD
min_value: 0
max_value: 36
The sensor component allows values from 0 to 36, and the slider appears normally in GUI, however, when I set this value to x, it actually sets it to x + 5. This happens for all values I set between 0 and 28. When I set a value from 29 to 36, it always returns 34. Seems like its on a mission to wind me up.
Here is a log of when I set the component:
[11:55:44][D][number:054]: 'Set Temperature' - Setting number value
[11:55:44][D][number:113]: New number value: 13.000000
[11:55:44][D][modbus.number:061]: Updating register: connected Sensor=Set Temperature start address=0x3E9 register count=1 new value=13.00 (val=13.00)
[11:55:44][D][number:012]: 'Set Temperature': Sending state 13.000000
[11:55:44][D][uart_debug:114]: >>> 01:06:03:F9:00:0D:98:7A
[11:55:44][D][number:012]: 'Set Temperature': Sending state 13.000000
[11:55:45][D][uart_debug:114]: <<< 01:06:03:F9:00:0D:98:7A
This the value that it returns when it updates every minute or so:
[11:56:32][D][modbus.number:023]: Number new state : 18.00
[11:56:32][D][number:012]: 'Set Temperature': Sending state 18.000000
Any help in understanding the problem would be much appreciated.
I have deleted device class and min/max from the yaml, but issue remains:
[11:29:14][D][number:054]: 'Set Temperature' - Setting number value
[11:29:14][D][number:113]: New number value: 2.000000
[11:29:14][D][modbus.number:061]: Updating register: connected Sensor=Set Temperature start address=0x3E9 register count=1 new value=2.00 (val=2.00)
[11:29:14][D][number:012]: 'Set Temperature': Sending state 2.000000
[11:29:14][D][uart_debug:114]: >>> 01:06:03:F9:00:02:D8:7E
[11:29:14][D][number:012]: 'Set Temperature': Sending state 2.000000
[11:29:14][D][uart_debug:114]: <<< 01:06:03:F9:00:02:D8:7E
[11:29:59][D][uart_debug:114]: >>> 01:03:03:E9:00:18:94:70
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 121.00
[11:29:59][D][sensor:094]: 'Evaporator 1 Temperature': Sending state 12.10000 °C with 0 decimals of accuracy
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 65136.00
[11:29:59][D][sensor:094]: 'Evaporator 2 Temperature': Sending state 6513.60010 °C with 0 decimals of accuracy
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 156.00
[11:29:59][D][sensor:094]: 'Condenser Temperature': Sending state 15.60000 °C with 0 decimals of accuracy
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 65136.00
[11:29:59][D][sensor:094]: 'Aux Temperature Sensor': Sending state 6513.60010 °C with 0 decimals of accuracy
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 178.00
[11:29:59][D][sensor:094]: 'Ambiant Temperature': Sending state 17.80000 °C with 1 decimals of accuracy
[11:29:59][D][modbus_controller.sensor:025]: Sensor new state: 540.00
[11:29:59][D][sensor:094]: 'Ambiant Humidity': Sending state 54.00000 % with 0 decimals of accuracy
[11:29:59][D][modbus.number:023]: Number new state : 56.00
[11:29:59][D][number:012]: 'Set Relative Humidity': Sending state 56.000000
[11:29:59][D][modbus.number:023]: Number new state : 40.00
[11:29:59][D][number:012]: 'Set RH Value for ExFan Start': Sending state 40.000000
[11:29:59][D][modbus.number:023]: Number new state : 7.00
[11:29:59][D][number:012]: 'Set Temperature': Sending state 7.000000
[11:29:59][W][component:237]: Component modbus_controller took a long time for an operation (59 ms).
[11:29:59][W][component:238]: Components should block for at most 30 ms.
[11:29:59][D][uart_debug:114]: <<< 01:03:30:00:00:00:00:00:00:00:00:00:00:00:00:00:01:00:00:00:79:FE:70:00:9C:FE:70:00:B2:02:1C:00:38:00:28:00:07:00:00:00:01:00:00:00:00:00:00:00:00:00:00:DF:B5
[11:29:59][D][uart_debug:114]: >>> 01:03:04:05:00:03:14:FA
[11:29:59][D][uart_debug:114]: <<< 01:03:06:00:00:00:00:00:00:21:75
Hex 00:38:00:28:00:07 is 56:40:7 in dec.
So it looks like your slave is adding to that register. And Esphome reads that and update the number.
Some calibration offset maybe?
What is that slave device by the way?
The slave device is a wall-mounted dehumidifier, which is mounted with an optionnal heating element. I have asked the manufacturer whether they can explain this behaviour. I note the modbus documention is wrong as it indicates min/max values of 0/36, whereas the user manual indicates 5/34. This however doesnt explain why it offsets by 5. Perhaps I can use a lambda to -5 the value I send in the command. Need to look that up as I have never managed to make lambdas work.
Modbus number has option: write_lambda (Optional, lambda): Lambda called before send. Lambda is evaluated before the modbus write command is created.
There is example on documentation.
But the question is what is the correct temperature? The one you set or the +5 one? Is it some factory calibration offset? Maybe there is a register for that offset, did you read all the registers?
If the correct value is what you were setting, then just ignore the +5 offset your slave reports.
You could use template number to set the temp and automation to set the modbus number. Then just use that template number and ignore what you have on modbus number (set option internal: true).
I hate R/W registers, you never know how they behave…