Skip to content

Commit

Permalink
Add 3ph program mode (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerza authored Jan 9, 2025
1 parent 1e498de commit ab994a1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions hass-addon-sunsynk-multi/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# FROM ghcr.io/kellerza/hass-addon-sunsynk-multi/armhf:edge
# FROM ghcr.io/kellerza/hass-addon-sunsynk-multi/armhf:0.7.5
# FROM ghcr.io/kellerza/hass-addon-sunsynk-multi:edge
# FROM ghcr.io/kellerza/hass-addon-sunsynk-multi:0.7.5
FROM ghcr.io/kellerza/hass-addon-sunsynk-multi:7a2597f


# Install sunsynk from local source
COPY sunsynk sunsynk
RUN pip3 install -e ./sunsynk[pymodbus,umodbus,solarman] --no-cache-dir --disable-pip-version-check
Expand Down
13 changes: 13 additions & 0 deletions src/sunsynk/definitions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

from sunsynk.sensors import EnumSensor, SerialSensor

PROG_CHARGE_OPTIONS = {
0: "No Grid or Gen",
1: "Allow Grid",
2: "Allow Gen",
3: "Allow Grid & Gen",
}
PROG_MODE_OPTIONS = {
0 << 2: "None",
1 << 2: "General",
2 << 2: "Backup",
3 << 2: "Charge",
}

DEVICE_TYPE = EnumSensor(
0,
"Device type",
Expand Down
14 changes: 1 addition & 13 deletions src/sunsynk/definitions/single_phase.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Sunsynk 5kW&8kW hybrid inverter sensor definitions."""

from sunsynk import AMPS, CELSIUS, KWH, VOLT, WATT
from sunsynk.definitions import DEVICE_TYPE, SERIAL_SENSOR
from sunsynk.definitions import DEVICE_TYPE, PROG_CHARGE_OPTIONS, PROG_MODE_OPTIONS, SERIAL_SENSOR
from sunsynk.rwsensors import (
NumberRWSensor,
SelectRWSensor,
Expand Down Expand Up @@ -262,18 +262,6 @@
PROG6_TIME.max = PROG1_TIME
SENSORS += (PROG1_TIME, PROG2_TIME, PROG3_TIME, PROG4_TIME, PROG5_TIME, PROG6_TIME)

PROG_CHARGE_OPTIONS = {
0: "No Grid or Gen",
1: "Allow Grid",
2: "Allow Gen",
3: "Allow Grid & Gen",
}
PROG_MODE_OPTIONS = {
0: "None",
4: "General",
8: "Backup",
16: "Charge",
}

SENSORS += (
# The max power that can be used from the battery
Expand Down
27 changes: 13 additions & 14 deletions src/sunsynk/definitions/three_phase_common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Sunsynk 5kW&8kW hybrid 3-phase inverter sensor definitions."""

from sunsynk import AMPS, CELSIUS, KWH, VOLT, WATT
from sunsynk.definitions import DEVICE_TYPE, SERIAL_SENSOR
from sunsynk.definitions import DEVICE_TYPE, PROG_CHARGE_OPTIONS, PROG_MODE_OPTIONS, SERIAL_SENSOR
from sunsynk.rwsensors import (
NumberRWSensor,
SelectRWSensor,
Expand Down Expand Up @@ -314,13 +314,6 @@
PROG6_TIME.max = PROG1_TIME
SENSORS += (PROG1_TIME, PROG2_TIME, PROG3_TIME, PROG4_TIME, PROG5_TIME, PROG6_TIME)

PROG_CHARGE_OPTIONS = {
0: "No Grid or Gen",
1: "Allow Grid",
2: "Allow Gen",
3: "Allow Grid & Gen",
}

SENSORS += (
SwitchRWSensor(
146,
Expand Down Expand Up @@ -350,12 +343,18 @@
NumberRWSensor(169, "Prog4 Capacity", "%", min=BATTERY_LOW_CAP),
NumberRWSensor(170, "Prog5 Capacity", "%", min=BATTERY_LOW_CAP),
NumberRWSensor(171, "Prog6 Capacity", "%", min=BATTERY_LOW_CAP),
SelectRWSensor(172, "Prog1 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(173, "Prog2 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(174, "Prog3 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(175, "Prog4 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(176, "Prog5 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(177, "Prog6 charge", options=PROG_CHARGE_OPTIONS),
SelectRWSensor(172, "Prog1 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(173, "Prog2 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(174, "Prog3 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(175, "Prog4 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(176, "Prog5 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(177, "Prog6 charge", options=PROG_CHARGE_OPTIONS, bitmask=0x03),
SelectRWSensor(172, "Prog1 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
SelectRWSensor(173, "Prog2 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
SelectRWSensor(174, "Prog3 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
SelectRWSensor(175, "Prog4 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
SelectRWSensor(176, "Prog5 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
SelectRWSensor(177, "Prog6 mode", options=PROG_MODE_OPTIONS, bitmask=0x1C),
)


Expand Down

0 comments on commit ab994a1

Please sign in to comment.