petrleocompel / hikaxpro_hacs

HACS repository of Hikvision Ax Pro integration for home assistant
MIT License
40 stars 4 forks source link

crash on parsing `related_pircam` #120

Closed gmusante closed 1 month ago

gmusante commented 1 month ago

After adding the AX-Pro to home assistant it's show the success message with and alert "Failed to set up"

2024-08-04 17:38:40.857 DEBUG (SyncWorker_8) [hikaxpro] Session_Capabilities response
2024-08-04 17:38:40.857 DEBUG (SyncWorker_8) [hikaxpro] Status: 200

2024-08-04 17:38:40.857 DEBUG (SyncWorker_8) [hikaxpro] Headers: {'Date': 'Sun, 04 Aug 2024 17:41:53 GMT', 'Server': 'Webs', 'X-Frame-Options': 'SAMEORIGIN', 'Cache-Control': 'no-cache', 'Content-Length': '568', 'Content-Type': 'application/xml; charset="UTF-8"', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=60, max=99'}

2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] Connect response
2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] Status: 200
2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] Content: b'<SessionLogin version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">\n<statusValue>200</statusValue>\n<statusString>OK</statusString>\n<isRiskPassword>false</isRiskPassword>\n<isActivated>true</isActivated>\n</SessionLogin>\n'
2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] Text: <SessionLogin version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<statusValue>200</statusValue>
<statusString>OK</statusString>
<isRiskPassword>false</isRiskPassword>
<isActivated>true</isActivated>
</SessionLogin>

2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] Headers: {'Date': 'Sun, 04 Aug 2024 17:41:53 GMT', 'Server': 'Webs', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Length': '228', 'Content-Type': 'application/xml; charset="UTF-8"', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=60, max=99', 'Cache-Control': 'no-cache="set-cookie"', 'Set-Cookie': 'WebSession_7d70177889=1ab0fdcebd58488ed8b7b6b695afa1d9e47d353cb6cbc0c9cc2b57a7c6477561;path=/;HttpOnly'}
2024-08-04 17:38:41.115 DEBUG (SyncWorker_8) [hikaxpro] End connect response
2024-08-04 17:38:41.129 DEBUG (SyncWorker_21) [custom_components.hikvision_axpro] <DeviceInfo version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<deviceName>AX PRO</deviceName>
<deviceID><--- redacted ---></deviceID>
<model>DS-PWA48-M-WB</model>
<serialNumber><--- redacted ---></serialNumber>
<macAddress><--- redacted ---></macAddress>
<firmwareVersion>V1.2.51</firmwareVersion>
<firmwareReleasedDate>build 220309</firmwareReleasedDate>
<hardwareVersion>0x1000</hardwareVersion>
<encoderVersion>V1.0</encoderVersion>
<encoderReleasedDate>build 000000</encoderReleasedDate>
<deviceType>PWA</deviceType>
<telecontrolID>0</telecontrolID>
<charEncodeFormat>GB2312</charEncodeFormat>
<languageType opt="english,spanish,portuguese,italian,french,russian,german,polish,czech,greek,turkish,dutch,hungarian,croatian,ukrainian,brazilianPortuguese,slovenian,swedish,norwegian,romanian,danish">english</languageType>
<customizedInfo></customizedInfo>
</DeviceInfo>

2024-08-04 17:38:41.129 DEBUG (SyncWorker_21) [custom_components.hikvision_axpro] {'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.hikvision.com/ver20/XMLSchema', 'deviceName': 'AX PRO', 'deviceID': '<--- redacted --->', 'model': 'DS-PWA48-M-WB', 'serialNumber': '<--- redacted --->', 'macAddress': '<--- redacted --->', 'firmwareVersion': 'V1.2.51', 'firmwareReleasedDate': 'build 220309', 'hardwareVersion': '0x1000', 'encoderVersion': 'V1.0', 'encoderReleasedDate': 'build 000000', 'deviceType': 'PWA', 'telecontrolID': '0', 'charEncodeFormat': 'GB2312', 'languageType': {'@opt': 'english,spanish,portuguese,italian,french,russian,german,polish,czech,greek,turkish,dutch,hungarian,croatian,ukrainian,brazilianPortuguese,slovenian,swedish,norwegian,romanian,danish', '#text': 'english'}, 'customizedInfo': None}}
2024-08-04 17:38:41.138 DEBUG (SyncWorker_21) [custom_components.hikvision_axpro] { "List": [ { "Zone": { "id": 0, "zoneName": "puerta principal ", "detectorType": "magneticContact", "zoneType": "Instant", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "continuous", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q16847756", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 1, 2, 3, 4, 5 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ 4 ], "linkageZone": [ ] }, "finalDoorExitEnabled": false } }, { "Zone": { "id": 1, "zoneName": "lavadero ", "detectorType": "magneticContact", "zoneType": "Instant", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q16846922", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 2, 3, 4, 5 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ 4 ], "linkageZone": [ ] }, "finalDoorExitEnabled": false } }, { "Zone": { "id": 2, "zoneName": "puerta garaje ", "detectorType": "magneticContact", "zoneType": "Instant", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q16847682", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 1, 3, 4, 5 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ 4 ], "linkageZone": [ ] }, "finalDoorExitEnabled": false } }, { "Zone": { "id": 3, "zoneName": "Oficina ", "detectorType": "magneticContact", "zoneType": "Instant", "subSystemNo": 2, "linkageSubSystem": [ 2 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q16847698", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 1, 2, 4, 5 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ 4 ], "linkageZone": [ ] }, "finalDoorExitEnabled": false } }, { "Zone": { "id": 4, "zoneName": "Quincho ", "detectorType": "pircam", "zoneType": "Instant", "subSystemNo": 2, "linkageSubSystem": [ 2 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q11888739", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 1, 2, 3, 5 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false } }, { "Zone": { "id": 5, "zoneName": "Oficina ", "detectorType": "passiveInfraredDetector", "zoneType": "Instant", "subSystemNo": 2, "linkageSubSystem": [ 2 ], "supportLinkageSubSystemList": [ 1, 2 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "tigger", "timeout": 30, "relateDetector": true, "detectorSeq": "Q14389381", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0 } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 1, 2, 3, 4 ], "alreadyAssociatedZone": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ 4 ], "linkageZone": [ ] } } } ] }
2024-08-04 17:38:41.138 WARNING (SyncWorker_21) [custom_components.hikvision_axpro.model] Invalid CrossZoneCfg {'isAssociated': False, 'supportAssociatedZone': [1, 2, 3, 4, 5], 'alreadyAssociatedZone': [], 'associateTime': 1800}
2024-08-04 17:38:41.139 WARNING (SyncWorker_21) [custom_components.hikvision_axpro.model] Detector info: {'id': 0, 'zoneName': 'puerta principal ', 'detectorType': 'magneticContact', 'zoneType': 'Instant', 'subSystemNo': 1, 'linkageSubSystem': [1], 'supportLinkageSubSystemList': [1, 2], 'enterDelay': 30, 'exitDelay': 30, 'stayArmDelayTime': 30, 'sirenDelayTime': 0, 'stayAwayEnabled': False, 'chimeEnabled': False, 'silentEnabled': False, 'chimeWarningType': 'continuous', 'timeoutType': 'tigger', 'timeout': 30, 'relateDetector': True, 'detectorSeq': 'Q16847756', 'RelatedChanList': [{'RelatedChan': {'relator': 'app', 'cameraSeq': '', 'relatedChan': 0}}], 'doubleKnockEnabled': False, 'doubleKnockTime': 5, 'CrossZoneCfg': {'isAssociated': False, 'supportAssociatedZone': [1, 2, 3, 4, 5], 'alreadyAssociatedZone': [], 'associateTime': 1800}, 'newKeyZoneTriggerTypeCfg': 'zoneStatus', 'zoneStatusCfg': 'triggerArm', 'armNoBypassEnabled': False, 'RelatedPIRCAM': {'supportLinkageZones': [4], 'linkageZone': []}, 'finalDoorExitEnabled': False}
2024-08-04 17:38:41.141 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Hikvision_axpro_192.168.2.199 for hikvision_axpro
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 107, in async_setup_entry
    await hass.async_add_executor_job(coordinator.init_device)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 185, in init_device
    self.load_devices()
  File "/config/custom_components/hikvision_axpro/__init__.py", line 223, in load_devices
    devices = self._load_devices()
              ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 236, in _load_devices
    return ZonesConf.from_dict(response.json())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 984, in from_dict
    list = from_list(ZoneConfListWrap.from_dict, obj.get("List"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 29, in from_list
    return [f(y) for y in x]
            ^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 968, in from_dict
    zone = ZoneConfig.from_dict(obj.get("Zone"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 774, in from_dict
    related_pircam = from_union([RelatedPIRCAM.from_dict, from_none], obj.get("RelatedPIRCAM"))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 43, in from_union
    assert False
           ^^^^^
AssertionError
petrleocompel commented 1 month ago

Fixed and released Version released 2.1.4