1. intro

  • homeassistant: 192.168.0.4

  • charger: 192.168.0.81

  • name: king_0682

2. modbus-proxy

curl -ns http://d01cid.ddns.net/sharel/bin/inst-modbus-proxy | bash
vi /etc/modbus-proxy.yaml
#
devices:

- modbus:
    url: 192.168.0.81:502
  listen:
    bind: 0:10502
systemctl enable --now modbus-proxy.service

3. modbus

ha-modbus -t alfen -e king_0682 -i 192.168.0.4 -p 10502 | tee /config/custom_components/alfen/etc/modbus/king_0682.yaml
ln -sv /config/custom_components/alfen/etc/modbus/king_0682.yaml /config/modbus/
sed -i s~"#modbus:"~"modbus:"~ /config/configuration.yaml
systemctl restart homeassistant.service

4. helpers

curl -ns http://d01cid.ddns.net/sharel/bin/ha-alfen-helpers | bash

5. debugging

5.1. modbus-proxy

scanport localhost
. 22    -> ssh
. 8123  -> homeassist
. 10502 -> modbus-proxy <<<

5.2. modpoll

  • number of phases

    modpoll -p 10502 -a 1 -r 1216 -t 4:hex -1 192.168.0.4
///
[1216]: 0x0003
  • max current

    modpoll -p 10502 -a 1 -r 1211 -t 4:hex -1 192.168.0.4
///
[1211]: 0x40C0

5.3. ha entities

  • number of phases

    grep "1_or_3" /config/getstates.dmp
208 | sensor.king_0682_charge_using_1_or_3_phases_socket1 | king_0682_charge_using_1_or_3_phases_socket1 | 2025-02-27 18:32:48 | 3 |
  • max current

    grep "max_current " /config/getstates.dmp
206 | sensor.king_0682_actual_applied_max_current_socket1 | king_0682_actual_applied_max_current_socket1 | 2025-02-27 18:32:46 | 16.00 |