Can't send negative values for victron modbus

I try to send negative values via the modbus service to victron but I get an error for negative values.
How can I solve this ?

Sent uint16 equivalent

I don’t think I understand your solution.
I have to send something like :
{
“address”: “2700”,
“value”: “10”,
“hub”: “victron”
}
As soon as I make the value negative I get the error.

I tried the same with the development service tab. Same error as soon as I send negative values.
How would your solution look like ?

Value 65526

Ok, but how do I send this hex number as a value in home assistant ?

65526 is a decimal number.

usually negative numbers in Modbus are requested as signed integers either int16 or int32 which have a range from -32768 to 32767 or -2,147,483,648 to +2,147,483,647 respectively. If using unsigned uint16 or uint32 the ranges are from 0 to 65535 and 0 to 4294967295.
This might be completely erroneous for your situation but just putting it out there.

thanks a lot, it works. I could just send the value 65525 and it sets it to -10

1 Like

what do you send to your victron?
I would change adress 2700 to a negative value, but it doesn’t work.
this is my code:


- id: '1678392352553'
  alias: Modbus schrijven
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_number.instelwatt
  condition: []
  action:
  - service: modbus.write_register
    data:
      hub: victron
      slave: 100
      address: 2700
      value: '{{ states(''input_number.instelwatt'') | int }}'

when instelwatt is above zero it works, but not negative

for negative values send a value of 65535 - input_number.instelwatt

example -1000 watt would be a value of 64535