Skip to content

Commit

Permalink
- log unregistered device when parsing packet
Browse files Browse the repository at this point in the history
  • Loading branch information
YOGYUI committed Jun 17, 2023
1 parent ad6aa25 commit 4cba376
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Hillstate-Gwanggyosan/Include/Define/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, name: str = 'Device', index: int = 0, room_index: int = 0):

def __repr__(self) -> str:
# repr_txt = f'<{self.name}({self.__class__.__name__} at {hex(id(self))}) '
repr_txt = f'<{self.name} '
repr_txt = f'<{self.__class__.__name__}, {self.name}, '
repr_txt += f'Dev Idx: {self.index}, '
repr_txt += f'Room Idx: {self.room_index}'
repr_txt += '>'
Expand Down
2 changes: 1 addition & 1 deletion Hillstate-Gwanggyosan/Include/Define/Outlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setDefaultName(self):

def __repr__(self):
# repr_txt = f'<{self.name}({self.__class__.__name__} at {hex(id(self))}) '
repr_txt = f'<{self.name} '
repr_txt = f'<{self.__class__.__name__}, {self.name}, '
repr_txt += f'Dev Idx: {self.index}, '
repr_txt += f'Room Idx: {self.room_index}, '
repr_txt += f'Enable Off Cmd: {self.enable_off_command}'
Expand Down
9 changes: 8 additions & 1 deletion Hillstate-Gwanggyosan/Include/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Home:
discover_device: bool = False
discovered_dev_list: List[Device]

verbose_unreg_dev_packet: bool = False

def __init__(self, name: str = 'Home', init_service: bool = True):
self.name = name
self.device_list = list()
Expand Down Expand Up @@ -258,6 +260,10 @@ def loadConfig(self):
self.parser_mapping[BatchOffSwitch] = int(parser_mapping_node.find('batchoffsw').text)
self.parser_mapping[HEMS] = int(parser_mapping_node.find('hems').text)

verbose_unreg_dev_packet_node = node.find('verbose_unreg_dev_packet')
if verbose_unreg_dev_packet_node is not None:
self.verbose_unreg_dev_packet = bool(int(verbose_unreg_dev_packet_node.text))

entry_node = node.find('entry')
dev_entry_cnt = len(list(entry_node))

Expand Down Expand Up @@ -514,7 +520,8 @@ def updateDeviceState(self, result: dict):
room_idx = 0
device = self.findDevice(dev_type, dev_idx, room_idx)
if device is None:
# writeLog(f'handlePacketParseResult::Cannot find device ({dev_type}, {dev_idx}, {room_idx})', self)
if self.verbose_unreg_dev_packet:
writeLog(f'handlePacketParseResult::Device is not registered ({dev_type.name}, idx={dev_idx}, room={room_idx})', self)
return

if dev_type in [DeviceType.LIGHT, DeviceType.OUTLET, DeviceType.GASVALVE, DeviceType.BATCHOFFSWITCH]:
Expand Down
1 change: 1 addition & 0 deletions Hillstate-Gwanggyosan/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@
-->
</airquality>
</entry>
<verbose_unreg_dev_packet>0</verbose_unreg_dev_packet>
</device>
<thinq>
<enable>1</enable>
Expand Down

0 comments on commit 4cba376

Please sign in to comment.