Problems pushing sensor.data to Modbus

Hello there,

i try to send a value sensor.bad_raum_feuchtigkeit to modbus.

when i try in develpment - services - modbus.write_register

address: 9
unit: 255
hub: hub1
value: 17

everything works well, but

address: 9
unit: 255
hub: hub1
value: "{{ states('sensor.bad_raum_feuchtigkeit') | round }}"

doesn’t work.

Error: Fehler beim Aufrufen des Diensts modbus/write_register. expected int @ data['value'][0]

{{ states('sensor.bad_raum_feuchtigkeit') | round }} gives back the value 52 testet in templates…

What i’am doing wrong?

best regards Mario

Try conerting it to a float first:

value: "{{ states('sensor.bad_raum_feuchtigkeit') | float | round }}"

Hello, thanks for the awnser - no it doesn’t work.

I’ve tried:

{{ states('sensor.bad_raum_feuchtigkeit') | int }}
{{ states('sensor.bad_raum_feuchtigkeit') | float }}
{{ states('sensor.bad_raum_feuchtigkeit') | float * 10 | round | int}}
{{ states('sensor.bad_raum_feuchtigkeit') | round | int }}
{{ states('sensor.bad_raum_feuchtigkeit') | round }}
{{ states('sensor.bad_raum_feuchtigkeit') | float | round }}
{{ states.sensor.bad_raum_feuchtigkeit | round }}

the second and third line are sending back xx.x all other xx - none of this are working.

Maybe you can’t template this key.
Can you try if this is the case with something like:

value: "{{ 12 * 10 }}"

alos doesn’t work :frowning:

Error: modbus/write_register. expected int @ data['value'][0]

Is there another way to send this sensorvalue to modbus?

I don’t know, I’m not using modbus. Which version of Home Assistant are you running?
Did you try it from an automation instead of Developer Tools -> Services? Don’t think it makes any difference but would be worth a try.

2020.12.7

I’ve started with some Codesnips out of the inet in automation and script but it doesen’t work, so i decided to start at basic - try to send manual. If this works i will automate it.

No one an idea?