I am glad that I could help and support
Hi @Dawidh,
thanks for your contribution. I am using it right now and it works quite well. Now I am struggling with some more registers. From the docs flying around (here for instance home-assistant-saj-h2-modbus/saj-h2-modbus.zip at 7894f919d631bab8f46941f7a521d2a164d69b11 · stanus74/home-assistant-saj-h2-modbus · GitHub) I see registers starting from 0x3604 which seem to aim for charge control via grid. When I add these registers, I get just zeroes. During testing, before I added the ModBus sensors, there were “real” values in these registers.
I added the registers like this:
- name: Battery Charge Time Control
unique_id: ampere_battery_charge_time_ctrl
device_address: !secret ampere-storage-pro-device-address
address: 13828
input_type: input
data_type: uint16
precision: 0
state_class: measurement
scale: 1
scan_interval: 60
Any ideas, what I am doing wrong?
Update: Just checked again, the values are there. Don’t know what went wrong beforehand. Now trying to figure out, which registers to set to what values for charging from grid.
As far as I could see, only register 13895 (0x3647) is set to 14 to start loading from grid and set back to 0 to stop it. I built simple scripts to write these two values to the inverter and it works.
Here’s my scripts.yaml:
start_laden:
sequence:
- service: modbus.write_register
data:
hub: AmpereStoragePro
slave: 2
address: 13895
value: 14
stop_laden:
sequence:
- service: modbus.write_register
data:
hub: AmpereStoragePro
slave: 2
address: 13895
value: 0
Would you be okay with sharing the original endpoint resultsets you’re working against for the REST side of your implementation? I’m currently preparing a HA integration for the solar setup of a friend of mine, and while I’m super greatful for the sensor configuration I found in your github repo, I have the suspicion that there might be different versions of the inverter REST endpoints flying around
Concretely: when I compare your value templates for totalExport and totalImport, you use 2 different templates.
value_template: “{{(value_json.state.split(’ ')[0] | float) * (0.00000027777) }}”
vs
value_template: “{{ value_json.state[:-2] | float | multiply(0.00000027777) }}”
The endpoints from the setup of the friend of mine deliver the same value format for both endpoints:
“state”: “1.5357116E+8 Ws” for totalImport
“state”: “2.32375173E+9 Ws” for totalExport
So I was wondering if your endpoints provide different formats?
Thank you for the repo by the way, it’s a great help!
p.s.: I tried out both value templates for both values, and they in both cases deliver the same result.
Is there also a way to control the charging of the battery via solar (instead of controlling the charge via grid)? Was thinking about the scenario where the solar power isn’t enough to charge the battery AND e.g. power the washing machine or the over. So to avoid needing to import power from the grid, I’d rather stop charging the battery, either by detecting high loads, or by switching off battery charging during usual cooking times, or by controlling the battery charging in coordination with the runtime of a controllable washing machine.