added eb3a

This commit is contained in:
Patrick762 committed 2024-02-17 20:36:32 +01:00
1 parent 3d65d8b00f
commit e395c400b5
3 files changed
+99 -1

No files matched your search

@@ -0,0 +1,39 @@
"""EB3A fields."""
from typing import List
from ..utils.commands import ReadHoldingRegisters
from ..field_enums import ChargingMode, EcoShutdown, LedMode
from ..base_devices.ProtocolV1Device import ProtocolV1Device
class EB3A(ProtocolV1Device):
def __init__(self, address: str, sn: str):
super().__init__(address, "EB3A", sn)
# Details
self.struct.add_decimal_field("ac_input_voltage", 77, 1)
self.struct.add_uint_field("internal_dc_input_voltage", 86)
# Controls
self.struct.add_enum_field("led_mode", 3034, LedMode)
self.struct.add_bool_field("power_off", 3060)
self.struct.add_bool_field("eco_on", 3063)
self.struct.add_enum_field("eco_shutdown", 3064, EcoShutdown)
self.struct.add_enum_field("charging_mode", 3065, ChargingMode)
self.struct.add_bool_field("power_lifting_on", 3066)
@property
def polling_commands(self) -> List[ReadHoldingRegisters]:
return super().polling_commands + [
ReadHoldingRegisters(77, 1),
ReadHoldingRegisters(86, 1),
]
@property
def writable_ranges(self) -> List[range]:
return super().writable_ranges + [
3034,
3060,
range(3063, 3066),
]
@@ -3,7 +3,15 @@
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum, auto, unique from enum import Enum, auto, unique
from .field_enums import AutoSleepMode, OutputMode, SplitPhaseMachineType, UpsMode from .field_enums import (
AutoSleepMode,
ChargingMode,
EcoShutdown,
LedMode,
OutputMode,
SplitPhaseMachineType,
UpsMode,
)
@unique @unique
@@ -205,6 +213,34 @@ FIELD_ATTRIBUTES = {
name="Battery Range End", name="Battery Range End",
unit_of_measurement="%", unit_of_measurement="%",
), ),
"led_mode": FieldAttributes(
type=FieldType.ENUM,
setter=True,
name="LED Mode",
options=LedMode,
),
"eco_on": FieldAttributes(
type=FieldType.BOOL,
setter=True,
name="Eco Mode",
),
"eco_shutdown": FieldAttributes(
type=FieldType.ENUM,
setter=True,
name="Eco Shutdown",
options=EcoShutdown,
),
"charging_mode": FieldAttributes(
type=FieldType.ENUM,
setter=True,
name="Charging Mode",
options=ChargingMode,
),
"power_lifting_on": FieldAttributes(
type=FieldType.BOOL,
setter=False, # Disabled for safety reasons
name="Power Lifting",
),
} }
@@ -32,3 +32,26 @@ class UpsMode(Enum):
class SplitPhaseMachineType(Enum): class SplitPhaseMachineType(Enum):
SLAVE = 0 SLAVE = 0
MASTER = 1 MASTER = 1
@unique
class LedMode(Enum):
LOW = 1
HIGH = 2
SOS = 3
OFF = 4
@unique
class EcoShutdown(Enum):
ONE_HOUR = 1
TWO_HOURS = 2
THREE_HOURS = 3
FOUR_HOURS = 4
@unique
class ChargingMode(Enum):
STANDARD = 0
SILENT = 1
TURBO = 2