AIO3 must, of course, be connected to the Wifi.
Check the router/Fritzbox for AIO3 and note the IP address.
I use the following code in HA to query the relevant values via Mobus:
PV power, battery power, grid, and house.
The data is displayed on an Energy Flow card.
I use a separate Config File modbus.yaml:
- name: modbus-saj
type: tcp
host: 192.168.178.76
port: 502
message_wait_milliseconds: 1000
timeout: 5
delay: 3
sensors:
- name: modbus_register_block
slave: 1
address: 16495 # Der Start des Registerblocks.
count: 56 # Die Anzahl der Register im Block (16550 - 16495 + 1).
data_type: custom
structure: ">56h" # Passt die Struktur an die Anzahl der Register und den Datentyp an.
scan_interval: 10
in configuration.yaml:
modbus: !include modbus.yaml
template:
- sensor:
- name: modbus_total_pv_power
unit_of_measurement: "W"
device_class: power
state: >
{{ states('sensor.modbus_register_block').split(',')[54] }}
- name: modbus_sys_total_load_watt
unit_of_measurement: "W"
device_class: power
state: >
{{ states('sensor.modbus_register_block').split(',')[49] }}
- name: modbus_bat_power
unit_of_measurement: "W"
device_class: power
state: >
{{ states('sensor.modbus_register_block').split(',')[55] }}
- name: modbus_bat_energy_percent
unit_of_measurement: "%"
device_class: battery
state: >
{{ states('sensor.modbus_register_block').split(',')[0] | float * 0.01 }}
- name: modbus_total_grid_power_watt
unit_of_measurement: "W"
device_class: power
state: >
{{ states('sensor.modbus_register_block').split(',')[50] }}
Grid charging can also be controlled via AIO3.
However, this requires manually switching to “Time of Use” mode in the O&M App.
The registers for “Working Mode” and others are locked for R/W via AIO3.
BUT! The registers are writable for the start/end times of battery charging.
I use the following code to write the start and end times:
in scripts.yaml
start_laden:
sequence:
- service: modbus.write_register
data:
hub: modbus-saj
unit: 1
address: 13831
value: 5947 # 23:59
stop_laden:
sequence:
- service: modbus.write_register
data:
hub: modbus-saj
unit: 1
address: 13831
value: 20 # 0:20 Uhr
in a Automation its possible to call the Script “Start Laden” and “Stop Laden”
the Start Time Register must set to “0” # 0 Uhr
or get the Start and Endtime from the cheap Price Window to a Variable and write via modbus to Inverter
This is my next Project when i can switch to Energy Provider “Tibber” in April 2024.
SAJ Modbus Protocol PDF 2020 Version https://t.me/saj_nooficialoriginal/8487
for H2 Inverter ! dont use older Versions for example 2017
Registers for Start/End Time begin from 3606H