petrleocompel / hikaxpro_hacs

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

Error loading component with local wired contact sensor (AX PRO M2H) #53

Closed r0bb10 closed 1 year ago

r0bb10 commented 1 year ago

Hi, i got a brand new AX PRO (M2H version with integrated local cabled zones), the component fails if i enable a local magnetic door contact sensor wired to Z1 on the board in DEOL mode (normal closed contact with tamper detection). The AX PRO in on the latest 1.2.8 version.

image

Logger: homeassistant.config_entries
Source: custom_components/hikvision_axpro/model.py:43
Integration: hikvision_axpro
First occurred: 12:30:15 (1 occurrences)
Last logged: 12:30:15

Error setting up entry AX PRO M2H for hikvision_axpro
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 105, in async_setup_entry
    await hass.async_add_executor_job(coordinator.init_device)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 177, in init_device
    self.load_devices()
  File "/config/custom_components/hikvision_axpro/__init__.py", line 181, in load_devices
    devices = self._load_devices()
              ^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/__init__.py", line 194, in _load_devices
    return ZonesConf.from_dict(response.json())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 874, in from_dict
    list = from_list(ListElement.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 29, in <listcomp>
    return [f(y) for y in x]
            ^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 858, in from_dict
    zone = ZoneConfig.from_dict(obj.get("Zone"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 697, in from_dict
    detector_wiring_mode = from_union([DetectorWiringMode, from_none], obj.get("detectorWiringMode"))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 43, in from_union
    assert False
AssertionError

If i delete the sensor from the web gui (or the app) and reload the component it works and does not give any error.

Any hint on why?

petrleocompel commented 1 year ago

It is going to be missing DetectorWiringMode in documentation and we are not expecting it. Can you try in configuration to enable debug output and watch HA logs for "full config" and provide the "DetectorWiringMode" of that particular sensor. I will take a look to docs but it seems there is a lot stuff undocumented for long time.

petrleocompel commented 1 year ago

You can try to use "beta version" might be fixed already.

r0bb10 commented 1 year ago

It is going to be missing DetectorWiringMode in documentation and we are not expecting it. Can you try in configuration to enable debug output and watch HA logs for "full config" and provide the "DetectorWiringMode" of that particular sensor. I will take a look to docs but it seems there is a lot stuff undocumented for long time.

is this usefull somehow?

2023-07-05 21:07:52.443 DEBUG (SyncWorker_21) [hikaxpro] Session_Capabilities response
2023-07-05 21:07:52.443 DEBUG (SyncWorker_21) [hikaxpro] Status: 200
2023-07-05 21:07:52.443 DEBUG (SyncWorker_21) [hikaxpro] Content: b'<SessionLoginCap version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">\n<sessionID>337f2f4eddc8382208f5954f74fd3858fb072e1d088ad02529c34fbb00115867</sessionID>\n<challenge>b9b5aca90cba6e673a9ea1b01ea3550f</challenge>\n<iterations>100</iterations>\n<isSupportRTSPWithSession>true</isSupportRTSPWithSession>\n<isIrreversible>true</isIrreversible>\n<sessionIDVersion>2.1</sessionIDVersion>\n<salt>28CE86F037CCAD400E51DBDA5449AAE1563EEE046AC17C2707D76F46A20876FB</salt>\n<salt2>82158E88EE52E24F5BA0E04A2678120D7B15BBD96C760F98594C3F8FB4060083</salt2>\n</SessionLoginCap>\n'
2023-07-05 21:07:52.444 DEBUG (SyncWorker_21) [hikaxpro] Text: <SessionLoginCap version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<sessionID>337f2f4eddc8382208f5954f74fd3858fb072e1d088ad02529c34fbb00115867</sessionID>
<challenge>b9b5aca90cba6e673a9ea1b01ea3550f</challenge>
<iterations>100</iterations>
<isSupportRTSPWithSession>true</isSupportRTSPWithSession>
<isIrreversible>true</isIrreversible>
<sessionIDVersion>2.1</sessionIDVersion>
<salt>28CE86F037CCAD400E51DBDA5449AAE1563EEE046AC17C2707D76F46A20876FB</salt>
<salt2>82158E88EE52E24F5BA0E04A2678120D7B15BBD96C760F98594C3F8FB4060083</salt2>
</SessionLoginCap>
2023-07-05 21:07:52.444 DEBUG (SyncWorker_21) [hikaxpro] Headers: {'Date': 'Wed, 05 Jul 2023 21:07:46 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'}
2023-07-05 21:07:52.445 DEBUG (SyncWorker_21) [hikaxpro] End Session_Capabilities response
2023-07-05 21:07:52.445 DEBUG (SyncWorker_21) [hikaxpro] Debug data <SessionLoginCap version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<sessionID>337f2f4eddc8382208f5954f74fd3858fb072e1d088ad02529c34fbb00115867</sessionID>
<challenge>b9b5aca90cba6e673a9ea1b01ea3550f</challenge>
<iterations>100</iterations>
<isSupportRTSPWithSession>true</isSupportRTSPWithSession>
<isIrreversible>true</isIrreversible>
<sessionIDVersion>2.1</sessionIDVersion>
<salt>28CE86F037CCAD400E51DBDA5449AAE1563EEE046AC17C2707D76F46A20876FB</salt>
<salt2>82158E88EE52E24F5BA0E04A2678120D7B15BBD96C760F98594C3F8FB4060083</salt2>
</SessionLoginCap>
2023-07-05 21:07:52.948 DEBUG (SyncWorker_21) [hikaxpro] Connect response
2023-07-05 21:07:52.948 DEBUG (SyncWorker_21) [hikaxpro] Status: 200
2023-07-05 21:07:52.948 DEBUG (SyncWorker_21) [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'
2023-07-05 21:07:52.949 DEBUG (SyncWorker_21) [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>
2023-07-05 21:07:52.949 DEBUG (SyncWorker_21) [hikaxpro] Headers: {'Date': 'Wed, 05 Jul 2023 21:07:46 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_3c94130892=1ad4ddb3d6fb5ad64194866bc7e90e69bf20e7484a6ad25045d440f86ce464d1;path=/;HttpOnly'}
2023-07-05 21:07:52.949 DEBUG (SyncWorker_21) [hikaxpro] End connect response
2023-07-05 21:07:53.009 DEBUG (SyncWorker_30) [custom_components.hikvision_axpro] <DeviceInfo version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<deviceName>AX PRO</deviceName>
<deviceID>48513132-3934-3534-3937-acb92feea921</deviceID>
<model>DS-PWA96-M2H-WE</model>
<serialNumber>DS-PWA96-M2H-WE20220420AAWRQ12945497WU</serialNumber>
<macAddress>ac:b9:2f:ee:a9:21</macAddress>
<firmwareVersion>V1.2.88</firmwareVersion>
<firmwareReleasedDate>build 230216</firmwareReleasedDate>
<hardwareVersion>0x1000</hardwareVersion>
<encoderVersion>V1.0</encoderVersion>
<encoderReleasedDate>build 000000</encoderReleasedDate>
<deviceType>PWA</deviceType>
<telecontrolID>1</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,slovak,serbian,bulgarian,hebrew,lithuanian,anglicism,estonian,latvian">english</languageType>
<customizedInfo></customizedInfo>
</DeviceInfo>
2023-07-05 21:07:53.012 DEBUG (SyncWorker_30) [custom_components.hikvision_axpro] {'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.hikvision.com/ver20/XMLSchema', 'deviceName': 'AX PRO', 'deviceID': '48513132-3934-3534-3937-acb92feea921', 'model': 'DS-PWA96-M2H-WE', 'serialNumber': 'DS-PWA96-M2H-WE20220420AAWRQ12945497WU', 'macAddress': 'ac:b9:2f:ee:a9:21', 'firmwareVersion': 'V1.2.88', 'firmwareReleasedDate': 'build 230216', 'hardwareVersion': '0x1000', 'encoderVersion': 'V1.0', 'encoderReleasedDate': 'build 000000', 'deviceType': 'PWA', 'telecontrolID': '1', '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,slovak,serbian,bulgarian,hebrew,lithuanian,anglicism,estonian,latvian', '#text': 'english'}, 'customizedInfo': None}}
2023-07-05 21:07:53.035 DEBUG (SyncWorker_30) [custom_components.hikvision_axpro] { "List": [ { "Zone": { "id": 0, "zoneName": "Contatto Porta", "detectorType": "magneticContact", "zoneType": "Delay", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1 ], "enterDelay": 30, "exitDelay": 5, "stayArmDelayTime": 5, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "recover", "timeout": 30, "relateDetector": true, "RelatedChanList": [ { "RelatedChan": { "relator": "host", "cameraSeq": "", "relatedChan": 0, "linkageCameraName": "" } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ ], "alreadyAssociatedZone": [ ], "supportLinkageChannelID": [ ], "alreadyLinkageChannelID": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ ], "linkageZone": [ ], "linkagePIRCAMName": "" }, "finalDoorExitEnabled": false, "timeRestartEnabled": false, "armMode": "and", "swingerLimitActivation": 3, "detectorWiringMode": "SEOL", "detectorAccessMode": "NC", "antiMaskingEnabled": true, "AMMode": "arm", "AMDelayTime": 60, "pulseSensitivity": 250, "alarmResistence": 2.2, "tamperResistence": 2.2, "moduleChannel": 1, "doubleZoneCfgEnable": false, "accessModuleType": "localTransmitter", "zoneAttrib": "wired" } } ] }
2023-07-05 21:07:53.038 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry AX PRO M2H for hikvision_axpro
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/__init__.py", line 105, in async_setup_entry
await hass.async_add_executor_job(coordinator.init_device)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/__init__.py", line 177, in init_device
self.load_devices()
File "/config/custom_components/hikvision_axpro/__init__.py", line 181, in load_devices
devices = self._load_devices()
^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/__init__.py", line 194, in _load_devices
return ZonesConf.from_dict(response.json())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 874, in from_dict
list = from_list(ListElement.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 29, in <listcomp>
return [f(y) for y in x]
^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 858, in from_dict
zone = ZoneConfig.from_dict(obj.get("Zone"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 698, in from_dict
detector_access_mode = from_union([DetectorAccessMode, from_none], obj.get("detectorAccessMode"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 43, in from_union
assert False
AssertionError
r0bb10 commented 1 year ago

You can try to use "beta version" might be fixed already.

i cant see any new beta version, only b15 in the releases, not yet published?

btw today the axpro firmware updated to 1.2.88, no changes.

petrleocompel commented 1 year ago

I mean beta version of integration. I fixed your problem in 2.0.0-beta16.

r0bb10 commented 1 year ago

works now, updated to b17, great work!