Hi @hollie ,
Thank you so much for doing all the work and sharing it.
Couldn’t have figured it out without this.
For people wanting to do the conversion from the desired Amperage in float32 to the two int16 values: Home Assistant Jinja templates (Python) also support the pack
and unpack
functions. So this is the script I used:
alias: set_modbus_maxcurrent
variables:
value_a: 0
sequence:
- service: modbus.write_register
data:
address: 1210
unit: 1
hub: chargepoint
value:
- "{{ (value_a | pack(\">f\") | unpack(\">I\")) // 2**16 }}"
- "{{ (value_a | pack(\">f\") | unpack(\">I\")) % 2**16 }}"
mode: single
I created an automation that calls this script, so everything is handled in Home Assistant. Some helper input booleans and numbers allow controlling the charging process from a dashboard.
Cheers,
Tars