added basic v1 and v2 protocol devices
This commit is contained in:
1 parent
f6f19b27e1
commit
4231b34bb8
3 files changed
+169
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""Base device definition for V1 Protocol devices."""
|
||||
|
||||
from typing import List
|
||||
|
||||
from ..utils.commands import ReadHoldingRegisters
|
||||
from ..utils.struct import DeviceStruct
|
||||
from .BluettiDevice import BluettiDevice
|
||||
|
||||
|
||||
class ProtocolV1Device(BluettiDevice):
|
||||
def __init__(self, address: str, type: str, sn: str):
|
||||
self.struct = DeviceStruct()
|
||||
|
||||
# Device info
|
||||
self.struct.add_string_field('device_type', 10, 6)
|
||||
self.struct.add_sn_field('serial_number', 17)
|
||||
|
||||
# Power IO
|
||||
self.struct.add_uint_field('dc_input_power', 36)
|
||||
self.struct.add_uint_field('ac_input_power', 37)
|
||||
self.struct.add_uint_field('ac_output_power', 38)
|
||||
self.struct.add_uint_field('dc_output_power', 39)
|
||||
|
||||
# Battery
|
||||
self.struct.add_uint_field('total_battery_percent', 43)
|
||||
|
||||
# Output state
|
||||
self.struct.add_bool_field('ac_output_on', 48)
|
||||
self.struct.add_bool_field('dc_output_on', 49)
|
||||
|
||||
# Output controls
|
||||
self.struct.add_bool_field('ac_output_on_switch', 3007)
|
||||
self.struct.add_bool_field('dc_output_on_switch', 3008)
|
||||
|
||||
super().__init__(address, type, sn)
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(10, 10),
|
||||
ReadHoldingRegisters(36, 4),
|
||||
ReadHoldingRegisters(43, 1),
|
||||
ReadHoldingRegisters(48, 2),
|
||||
]
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
return [range(3007, 3008)]
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Base device definition for V2 Protocol devices."""
|
||||
|
||||
from typing import List
|
||||
|
||||
from ..utils.commands import ReadHoldingRegisters
|
||||
from ..utils.struct import DeviceStruct
|
||||
from .BluettiDevice import BluettiDevice
|
||||
|
||||
|
||||
class ProtocolV2Device(BluettiDevice):
|
||||
def __init__(self, address: str, type: str, sn: str):
|
||||
self.struct = DeviceStruct()
|
||||
|
||||
# Device info
|
||||
self.struct.add_string_field('device_type', 110, 6)
|
||||
self.struct.add_sn_field('serial_number', 116)
|
||||
|
||||
# Power IO
|
||||
#self.struct.add_uint_field('dc_input_power', ?)
|
||||
#self.struct.add_uint_field('ac_input_power', ?)
|
||||
#self.struct.add_uint_field('ac_output_power', ?)
|
||||
#self.struct.add_uint_field('dc_output_power', ?)
|
||||
|
||||
# Battery
|
||||
self.struct.add_uint_field('total_battery_percent', 102)
|
||||
|
||||
# Output state
|
||||
#self.struct.add_bool_field('ac_output_on', ?)
|
||||
#self.struct.add_bool_field('dc_output_on', ?)
|
||||
|
||||
# Output controls
|
||||
#self.struct.add_bool_field('ac_output_on_switch', ?)
|
||||
#self.struct.add_bool_field('dc_output_on_switch', ?)
|
||||
|
||||
# Add battery fields here?
|
||||
|
||||
super().__init__(address, type, sn)
|
||||
|
||||
@property
|
||||
def polling_commands(self) -> List[ReadHoldingRegisters]:
|
||||
return [
|
||||
ReadHoldingRegisters(110, 6),
|
||||
ReadHoldingRegisters(116, 4),
|
||||
ReadHoldingRegisters(102, 1),
|
||||
]
|
||||
|
||||
@property
|
||||
def writable_ranges(self) -> List[range]:
|
||||
return []
|
||||
Reference in new issue
Block a user