added pack fields to base devices
This commit is contained in:
1 parent
cac64b40bd
commit
01cb7f35a5
3 files changed
+53
-2
No files matched your search
@@ -24,18 +24,24 @@ class FieldAttributes:
|
||||
@dataclass(frozen=True)
|
||||
class PowerFieldAttributes(FieldAttributes):
|
||||
type = FieldType.NUMERIC
|
||||
name: str
|
||||
unit_of_measurement = 'W'
|
||||
device_class = 'power'
|
||||
state_class = 'measurement'
|
||||
|
||||
@dataclass
|
||||
class VoltageFieldAttributes(FieldAttributes):
|
||||
type = FieldType.NUMERIC
|
||||
unit_of_measurement = 'V'
|
||||
device_class = 'voltage'
|
||||
state_class = 'measurement'
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class OutletFieldAttributes(FieldAttributes):
|
||||
type = FieldType.BOOL
|
||||
name: str
|
||||
device_class = 'outlet'
|
||||
|
||||
FIELD_ATTRIBUTES = {
|
||||
# Base device fields
|
||||
'dc_input_power': PowerFieldAttributes(
|
||||
name = 'DC Input Power',
|
||||
),
|
||||
@@ -48,6 +54,13 @@ FIELD_ATTRIBUTES = {
|
||||
'dc_output_power': PowerFieldAttributes(
|
||||
name = 'DC Output Power',
|
||||
),
|
||||
'power_generation': FieldAttributes(
|
||||
type = FieldType.NUMERIC,
|
||||
name = 'Total Power Generation',
|
||||
unit_of_measurement = 'kWh',
|
||||
device_class = 'energy',
|
||||
state_class = 'total_increasing',
|
||||
),
|
||||
'total_battery_percent': FieldAttributes(
|
||||
type = FieldType.NUMERIC,
|
||||
name = 'Total Battery Percent',
|
||||
@@ -55,6 +68,9 @@ FIELD_ATTRIBUTES = {
|
||||
device_class ='battery',
|
||||
state_class ='measurement',
|
||||
),
|
||||
'total_battery_voltage': VoltageFieldAttributes(
|
||||
name = 'Total Battery Voltage',
|
||||
),
|
||||
'ac_output_on': OutletFieldAttributes(
|
||||
name = 'AC Output',
|
||||
),
|
||||
@@ -69,4 +85,20 @@ FIELD_ATTRIBUTES = {
|
||||
name = 'DC Output',
|
||||
setter = True,
|
||||
),
|
||||
|
||||
# Device specific fields
|
||||
}
|
||||
|
||||
def PACK_FIELD_ATTRIBUTES(pack: int):
|
||||
return {
|
||||
'pack_voltage': VoltageFieldAttributes(
|
||||
name = f'Battery Pack {pack} Voltage',
|
||||
),
|
||||
'pack_battery_percent': FieldAttributes(
|
||||
type = FieldType,
|
||||
name = f'Battery Pack {pack} Percent',
|
||||
unit_of_measurement = '%',
|
||||
device_class ='battery',
|
||||
state_class ='measurement',
|
||||
),
|
||||
}
|
||||
Reference in new issue
Block a user