Hello,
I’m working on automation, which will regulate max charging current of my wallbox based on the surplus energy from my solar panels. I can read the data from my panels through existing integration, I’m able to use HASS modbus to read the data from my wallbox and as well in testing examples I’m able to write needed data to my wallbox through modbus to change maximu charging current. However, when I put some logic in part of automation which should write needed values to wallbox through modbus write service, it fails with errors like this:\
2023-07-16 13:09:26.290 ERROR (MainThread) [homeassistant.components.automation.power_divided_sensor_changed] Power Divided Sensor Changed: Error executing script. Invalid data for call_service at pos 1: expected int @ data['value'][0]
2023-07-16 13:09:26.295 ERROR (MainThread) [homeassistant.components.automation.power_divided_sensor_changed] Error while executing automation automation.power_divided_sensor_changed: expected int @ data['value'][0]
This is my automation, where I believe am sending array of two integers to modbus write service:
- alias: Power Divided Sensor Changed
trigger:
platform: state
entity_id: sensor.power_divided_sensor
action:
- service: modbus.write_register
data:
hub: ModbusWallbox
address: 1012
value: >
case states.sensor.power_divided_sensor.state:
when 0:
return !!python/tuple [0x0000, 0]
when 6:
return !!python/tuple [0x40C0, 0]
when 7:
return !!python/tuple [0x40E0, 0]
when 8:
return !!python/tuple[0x4100, 0]
when 9:
return !!python/tuple [0x4110, 0]
when 10:
return !!python/tuple [0x4120, 0]
when 11:
return !!python/tuple [0x4130, 0]
when 12:
return !!python/tuple [0x4140, 0]
when 13:
return !!python/tuple [0x4150, 0]
when 14:
return !!python/tuple [0x4160, 0]
when 15:
return !!python/tuple [0x4170, 0]
when 16:
return !!python/tuple [0x4180, 0]
else:
return !!python/tuple [0x4180, 0]
Sensor power_divided_sensor, helps me to calculate current I should set to wallbox to stay within surplus and returns integer number 0 or 6 to 16.
Thx for help!