petrleocompel / hikaxpro_hacs

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

Add support for additional devices and functions #14

Open DejanBukovec opened 1 year ago

DejanBukovec commented 1 year ago

We can make this integration very close to what HIK connect offer and what API allow us to do...

For example for PIRCAM sensor we can get picture from it: GET /ISAPI/SecurityCP/pircam/picture/channels/?format=json

One good feature will be AC status of panel: GET /ISAPI/SecurityCP/status/acPowerStatus?format=json

And battery status: GET /ISAPI/SecurityCP/status/batteries?format=json

Or maybe using next call to get more info(Also network...) GET /ISAPI/SecurityCP/status/host?format=json

There are availible also next Sensors which are currently not implemented(I don't have model ID for them): glassBreakDetector - PIR (Passive Infrared) glass-break detector indoorDualTechnologyDetector - Indoor dual-technology detector panicButton - Panic button wiredDetector - Wired detector

If you can implement support also for other(non sensor/detector) devices to change some settings it will be awesome: wirelessSiren - For example change volume, show temperature, battery, signal, bypass, tamper status GET /ISAPI/SecurityCP/status/sirenStatus?format=json

repeaters - Show if is ONLINE/OFFLINE GET /ISAPI/SecurityCP/status/repeaterStatus?format=json

keypadStatus - Show temperature, battery, signal, bypass, tamper status GET /ISAPI/SecurityCP/status/keypadStatus?format=json

For siren(Internal siren) and keypad(DS-PK1-LT-WE) I can be tester because I have them installed.

Let me know if you don't have access to Hikvision documentation that I provide more info...

petrleocompel commented 1 year ago

Would be interesting. Lot of potential..

GET /ISAPI/SecurityCP/pircam/picture/channels/?format=json - no clue how this would integrate to HA. More interesting would be trigger in my opinion.

GET /ISAPI/SecurityCP/status/host?format=json - contains even AC state, battery also and lot metadata info. For this intake of info would be better to split to 2 coordinators

GET /ISAPI/SecurityCP/status/sirenStatus?format=json - Sirens I am not sure about settings, but info should be pulled

GET /ISAPI/SecurityCP/status/repeaterStatus?format=json - repeaters - i think health contains it Definitely should be implemented

GET /ISAPI/SecurityCP/status/keypadStatus?format=json - keypadStatus - Definitely should be implemented

I will get later in to it and implement those

petrleocompel commented 1 year ago

I added endpoints to hikaxpro (fork) waiting for some pull requests https://github.com/petrleocompel/hikaxpro/commit/955a66c97ce5a86523b73cdd367da3096924fc3a

DejanBukovec commented 1 year ago

Thanks will wait for pull :)

leciuk81 commented 1 year ago

I have the following products already installed in addition to the repeater. If I can help you in any way, I'm available. Unfortunately not to write the code as I'm not good at it. sensors: DS-PDMCX-E-WE DS-PDPG12P-EG2-WE DS-PDPC12P-EG2-WE DS-PDMCK-EG2-WE DS-PDMC-EG2-WE

sirens: DS-PS1-I-WE DS-PS1-E-WE

tag readers: DS-PT1-WE

wireless keyfob: DS-PKF1-WE

I also installed the 2 magnetic contacts wired coupled with the radio contacts of the doors

DejanBukovec commented 1 year ago

You can test if devices which I and Peter don't have to test ... I don't have: DS-PS1-E-WE DS-PT1-WE Repeater

Does sensos which are connected over repeater in HA show "Is via repeater" True? You can compare and check in HIK Connect which sensor use repeater... I can't test this so not sure if work correctly... Siren and other non sensor devices are not included yet so is not shown in device list... When main python library will be updated(By other developer) then also other device info can be integrated so need to be patient until then...

petrleocompel commented 1 year ago

It is just about time and priorities. I am working on this in my spare time.

Currently I have done some research but I’m waiting on the pull request. If it will not be merged in some time I am going to fork the API library.

As @DejanBukovec said you can test stuff. But because you request it then obviously you are going to test it anyway.

leciuk81 commented 1 year ago

HI, I confirm that the sensors, even if connected through the repeater, are displayed in HA. Below I list what I tested and it is still not recognized in HA:

image

I'm available if you need debug just tell me

DejanBukovec commented 1 year ago

I have DS-PDPC12P-EG2-WE is PIRCAM sensor and it is supported and work: slika

DS-PDP15P-EG2-WE is normal PIR sensor(With PET imunity) and is supported and work(I also have them): slika

DS-PDPG12P-EG2-WE is wirelessGlassBreakDetector and is not supported yet but can be quick and simple added if you provide home assistant integration log file where we can see model id line in log which provide info like this: ZoneList(zone=Zone(id=3, name='Otroška Soba', status=<Status.ONLINE: 'online'>, tamper_evident=False, shielded=False, bypassed=False, armed=False, is_arming=False, alarm=False, sub_system_no=2, linkage_sub_system=[2], detector_type=<DetectorType.PASSIVE_INFRARED_DETECTOR: 'passiveInfraredDetector'>, stay_away=False, zone_type=<ZoneType.INSTANT: 'Instant'>, zone_attrib=<ZoneAttrib.WIRELESS: 'wireless'>, device_no=6, abnormal_or_not=False, charge='normal', charge_value=100, signal=121, temperature=21, humidity=None, model='0x00001', is_via_repeater=False, version='V1.0.25', magnet_open_status=None, input_list=None, is_support_add_type=None, access_module_type=None, module_channel=None))

petrleocompel commented 1 year ago

@DejanBukovec Today with version v0.8.0 i added mutliple detector types including wirelessGlassBreakDetector Just don't know what extra attrs it has.

@leciuk81 for you for your "door sensors" and additional wired contacts. Do you mean "wired sensors" or in some sensor are contact to wire ? Can you provide log ? enable debugging and find part of the log with the "name" matching the one which is missing those contacts.

DejanBukovec commented 1 year ago

But does not it need to be included also inside detector_model_to_name function? Or in latest versions this in not mantadory anymore?

Best will be if he provide full log file with Zone details it can be any of not complete implemented attribute... But without debug log from HA is only guessing... Maybe ZoneType make him problem which is not fully implemented... zone type: "Instant"-instant zone, "Delay"-delay zone, "Follow"-follow zone, "Perimeter"-perimeter zone, "24hNoSound"-24-hour silent zone, "Emergency"-panic zone, "Fire"-fire zone, "Gas"-gas zone, "Medical"-medical zone, "Timeout"-timeout zone, "Non-Alarm"-disabled zone, "Key"-key zone*

petrleocompel commented 1 year ago

@DejanBukovec Most of the attributes converted to enums are in try catch blocks so it will not crash. It will be just not used as known attribute. Also ZoneType is not used for anything now. detector_model_to_name is used only for displaying it in device list.

leciuk81 commented 1 year ago

@DejanBukovec - I updated to the latest version and I confirm what you said that all detectors are in HA except for the trigger.

@petrleocompel - by wired contacts I mean these:

WhatsApp Image 2023-03-03 at 00 05 59

below part of the debug log:

'zoneAttrib': 'wired', 'deviceNo': 22, 'abnormalOrNot': False}
2023-03-03 00:10:07.259 WARNING (SyncWorker_12) [custom_components.hikvision_axpro.model] Invalid accessModuleType inputMainZone
2023-03-03 00:10:07.264 WARNING (SyncWorker_12) [custom_components.hikvision_axpro.model] Detector info: {'id': 7, 'name': 'Finestra veranda (zona cablata 8)', 'status': 'online', 'sensorStatus': 'normal', 'tamperEvident': False, 'shielded': False, 'bypassed': False, 'armed': False, 'isArming': False, 'alarm': False, 'subSystemNo': 1, 'linkageSubSystem': [1], 'detectorType': 'other', 'stayAway': False, 'zoneType': 'Instant', 'accessModuleType': 'inputMainZone', 'relatedAccessModuleID': 6, 'moduleChannel': 1, 'zoneAttrib': 'wired', 'deviceNo': 22, 'abnormalOrNot': False}
petrleocompel commented 1 year ago

Strange that is not even in documentation.

"accessModuleType": "inputMainZone",
    "accessModuleType": {  
/*optional, object, access module type: "transmitter"-transmitter peripheral, "multiTransmitter", "localTransmitter", "localZone","keypad"*/
      "@opt": ["transmitter", "multiTransmitter", "localTransmitter", "localZone","keypad"]
    },
leciuk81 commented 1 year ago

However, it is recognized with diagnostics but without a trigger

image

image

petrleocompel commented 1 year ago

I think the trigger will not be present in attributes. It is same as #2. It is more "event". Not a attribute or in app you can see in device detail (in hikConnect) that contact is triggered?

leciuk81 commented 1 year ago

@petrleocompel I think you are right, I don't see the trigger in hikConnect either

DejanBukovec commented 1 year ago

I think but Im not test this yet when some sensor trigger when alarm panel is armed value of "Alarm" under diagnostic of sensor will change from Off to On ... When you confirm alarm(Disarm or confirm) or maybe also after some time it will automaticly reset to Off(Im not sure about this timer reset but if remember correct there under sensor is some option to enable/disable this)... I think I will have this weekend some time and will test and contribute more...

petrleocompel commented 1 year ago

@DejanBukovec behaviour should be:

Problem is.. Since we are pulling the data the alarm we don't see instantly. It is in "pull interval" (default 30s). And then we can find out what sensor it was if you did not disarm the system yet.

This can be changed but it requires configuration on AX Pro to sent the events to the HA. It would be amazing. But currently:

leciuk81 commented 1 year ago

Hi @petrleocompel, I noticed with pleasure that you made the wired magnet of the "Wireless Magnet Shock Detector DS-PDMCK-EG2-WE" visible and working, see images below:

image

image

Would you be able to make visible also the wired magnets of the "Wireless External Magnet Detector DS-PDMCX-E-WE" which as you see from the screenshots below is visible but the magnet is not activated.

image

image

You are doing a great job congratulations and thanks

petrleocompel commented 1 year ago

Can you provide debug log ? On integration enable debug logging wait 2 minutes, end debugging and provide the log. I will add support for this magnet initializiation

leciuk81 commented 1 year ago

Debug below

home-assistant_hikvision_axpro_2023-03-12T12-42-31.352Z.log

petrleocompel commented 1 year ago

Are you on latest version? I see in log -> problem with inputMainZone in enum AccessModuleType. If it is true then it is undocumented in their docs...

    "accessModuleType": {  
/*optional, object, access module type: "transmitter"-transmitter peripheral, "multiTransmitter", "localTransmitter", "localZone","keypad"*/
      "@opt": ["transmitter", "multiTransmitter", "localTransmitter", "localZone","keypad"]
    },

But it should not affect magnet. DOOR_MAGNETIC_CONTACT_DETECTOR aka detectorType = magneticContact is implemented from version 0.6.0.

Can you check your version ?

leciuk81 commented 1 year ago

image

leciuk81 commented 1 year ago

This works correctly:

2023-03-12 13:40:00.533 WARNING (SyncWorker_12) [custom_components.hikvision_axpro.model] Detector info: {'id': 7, 'name': 'Finestra veranda (zona cablata 8)', 'status': 'online', 'sensorStatus': 'normal', 'magnetOpenStatus': False, 'tamperEvident': False, 'shielded': False, 'bypassed': False, 'armed': False, 'isArming': False, 'alarm': False, 'subSystemNo': 1, 'linkageSubSystem': [1], 'detectorType': 'magneticContact', 'stayAway': False, 'zoneType': 'Instant', 'accessModuleType': 'inputMainZone', 'relatedAccessModuleID': 6, 'moduleChannel': 1, 'zoneAttrib': 'wired', 'deviceNo': 22, 'abnormalOrNot': False}

But this doesn't work:

2023-03-12 13:40:00.536 WARNING (SyncWorker_12) [custom_components.hikvision_axpro.model] Detector info: {'id': 19, 'name': 'Cassettina sali-scendi serranda (zona 20)', 'status': 'online', 'sensorStatus': 'normal', 'tamperEvident': False, 'shielded': False, 'bypassed': False, 'armed': True, 'isArming': False, 'alarm': False, 'subSystemNo': 2, 'linkageSubSystem': [2], 'detectorType': 'other', 'stayAway': False, 'zoneType': 'Instant', 'accessModuleType': 'inputMainZone', 'relatedAccessModuleID': 15, 'moduleChannel': 1, 'zoneAttrib': 'wired', 'deviceNo': 39, 'abnormalOrNot': False}
petrleocompel commented 1 year ago

I understand. But as you see

{
    "id": 19,
    "name": "Cassettina sali-scendi serranda (zona 20)",
    "status": "online",
    "sensorStatus": "normal",
    "tamperEvident": false,
    "shielded": false,
    "bypassed": false,
    "armed": true,
    "isArming": false,
    "alarm": false,
    "subSystemNo": 2,
    "linkageSubSystem": [2],
    "detectorType": "other",
    "stayAway": false,
    "zoneType": "Instant",
    "accessModuleType": "inputMainZone",
    "relatedAccessModuleID": 15,
    "moduleChannel": 1,
    "zoneAttrib": "wired",
    "deviceNo": 39,
    "abnormalOrNot": false
}

The system is not providing magnetStatusOpen attribute. We cannot anything from that.

petrleocompel commented 1 year ago

If understand what is happening now. If it is a wired detector. there is no more info provided. If system is armed and this contact will "trigger" it will trigger alarm. Since it is detectorType -> other. There is no info provided. You can check with mobile app even there should be now info about magnetStatus on sensor Cassettina sali-scendi serranda (zona 20)

leciuk81 commented 1 year ago

I understand but I'll give you more information. From the app wired contacts are not detected as status but work for alarm. Each magnetic contact has 2 wired contacts. As regards the sensor "Wireless Magnet Shock Detector DS-PDMCK-EG2-WE" you managed to make it visible in the home assistant but only one of the two and precisely contact 1 while for the sensor "Wireless External Magnet Detector DS-PDMCX- E-WE" they work correctly but not displayed in the home assistant. I understand if it is not possible but I try to give you more information in my tests. However, I have approved the second contacts for both and for this I am attaching the updated debug again.

Debug home-assistant_hikvision_axpro_2023-03-12T13-53-46.320Z.log

petrleocompel commented 1 year ago

You can check on your own. If the sensors in mobile app (HikConnect) does not provide info about what ever you need. We cannot get that info to HA.

In debug log I see the device. But no extra attributes. And they are wired. So they act as "cable interruptions" for alarm and not providing any information to alarm system. It is not a data cable. It is just a "contact cable" for alarm.

I have serval wired sensors like this. And it is not possible to get anything on them.

leciuk81 commented 1 year ago

Sorry but perhaps the use of the translator prevents me from expressing the clear concept. On the App there is the same information on all magnetic sensors. The state of the sensors wired to it is not present in any sensor. But in the wired contact 1 of the "Wireless Magnet Shock Detector DS-PDMCK-EG2-WE" sensor in the home assistant everything works great recognizing the status as in the figure below

image

petrleocompel commented 1 year ago

I am getting totally lost @leciuk81.

So DS-PDMCK-EG2-WE has 2 wired inputs extension. According to documentation they act as alarm triggers.

You can add two external inputs (each input can be set as NO\NC\TAMPER\Pulse) via the AX PRO client. While Any of the two inputs generates an alarm event, the contact reports the alarm to the AX PRO. The LED keeps blue for 2 s

So this info is not sent to any app. Only in configuration of that sensor you can set NO\NC\TAMPER\Pulse.

If you mean something else please try to describe from scratch full story, fully documented, (app screenshots) where you see info what you miss in HA.

leciuk81 commented 1 year ago

So DS-PDMCK-EG2-WE has 2 wired inputs extension. According to documentation they act as alarm triggers.

You can add two external inputs (each input can be set as NO\NC\TAMPER\Pulse) via the AX PRO client. While Any of the two inputs generates an alarm event, the contact reports the alarm to the AX PRO. The LED keeps blue for 2 s

So this info is not sent to any app. Only in configuration of that sensor you can set NO\NC\TAMPER\Pulse.

All of this is correct

These are the 2 contacts wired with the 3 wires zone 1, zone 2 and com image

This is an example by wiring zone 1 only WhatsApp Image 2023-03-12 at 20 33 30

In home assistant the wired contact is seen like this: image

If I open the window in WhatsApp Image 2023-03-12 at 20 47 34 WhatsApp Image 2023-03-12 at 20 47 34 (1)

The contact in home assistant looks like this: image

This all works great. I don't understand why this works with zone 1 and not with zone 2

If you see in the screenshot of zone 2, nothing is displayed in home assistant even though it is enabled. I have also made various tests by connecting the wired magnet but the status does not come out

image

In the app it is configured in the same way WhatsApp Image 2023-03-12 at 20 51 47

WhatsApp Image 2023-03-12 at 20 53 20

petrleocompel commented 1 year ago

In your log Zona cablata 22 is detectorType other so no info provided. :disappointed: That is the reason. Even in json received about this device does not have magnetStatus attribute.

I think the zone 1 is connected to main attribute of the magnet. The zone 2 is separate. This will be sadly on Hikvision implmentation.

petrleocompel commented 1 year ago

@DejanBukovec I took over pypi package of hikaxpro, released update version 2.0.0 and now I am maintainer of that repository. My work can finally start. Since we have full control over the package. I already pulled some changes over.

Now I can focus on more stuff which we can implement. Also found out there is no support for relay control 🤷‍♂️ completely forgot that I use them.

First I guess will be end point with Sirens, then relay control. And etc. Everybody is welcome to say what things are important and we can try prioritise.

NickCDevel commented 1 year ago

Hi, Thank you Petr for this soft! I have several detectors that are not yet well or fully recognized like Pircam (DS-PDPC12P-EG2-WE) and DS-PDCM15PF-IR + Hikvision DS-PDTT15AM-LM-WE. the first one is working for the detection but not for the image/video capture. I have been looking for a long time for a valid ISAPI and have done some testing myself, but I only get a 404 response with this URL: GET http://xxx.xxx.xxx.xxx/ISAPI/SecurityCP/pircam/picture/channels/?format=json @DejanBukovec : were you successful with this URL? Do you know how to find the ID parameter? i tried without success, zone and sensor number as well as their name, and number like 0, 1, 2 .... Curiously my Pircams are correctly listed and accessible in the "configuration" ISAPI (i.e: /ISAPI/SecurityCP/Configuration/pircam/zone?format=json) I can help develop if I can find a valid ISAPI url. For information, I am on the latest firmware available for AX pro. The doc is from december 2020, maybe it is out of date and a new version is available? does anyone have a more recent doc? Thanks for your help.

DejanBukovec commented 1 year ago

I didn't try URL's but it must look like: http://XXX.XXX.XXX.XXX/ISAPI/SecurityCP/pircam/picture/channels/4?format=json Where 4 is device number: slika

Afcourse before this I think you need estabilish session...

Doc: slika

petrleocompel commented 1 year ago

@NickCDevel Just warning that basic API connection should be done via hikaxpro library and this (repo) integration should just do the binding for HA. Right not you can find also the code of library inside, but next version should be gone. That is the reason why it takes me so much time. (It was needed for making AXHub working - for start).

The document matches the current ISAPI so far always. You can use shared session in library -> _cookie -> via axpro.make_request method.

You are welcome to make a pull request.

NickCDevel commented 1 year ago

I didn't try URL's but it must look like: http://XXX.XXX.XXX.XXX/ISAPI/SecurityCP/pircam/picture/channels/4?format=json Where 4 is device number: slika

Afcourse before this I think you need estabilish session...

Doc: slika

Hi, Thank you. But I already tried with this kind url: http://192.168.XXX.XXX/ISAPI/SecurityCP/pircam/picture/channels/2?format=json with "2" corresponding to the device number (i also tried with other number). but I get: "Can't locate the url" as answer. Of course I previously established a connection., since other ISAPI worked. I Thus wonder if this API was for axhub instead of ax pro or for for an anterior version... According to the doc for hikconnect pro api, stored pictures and videos in the control panel of the ax pro should also be accessible via a videourl (which is send for ARC) but i can't guess it...

NickCDevel commented 1 year ago

ust warning that basic API connection should be done via hikaxpro library and this (repo) integration should just do the binding for HA. Right not you can find also the code of library inside, but next version should be gone. That is the reason why it takes me so much time. (It was needed for making AXHub working - for start).

The document matches the current ISAPI so far always. You can use shared session in library -> _cookie -> via axpro.make_request method.

You are welcome to make a pull request.

Thank you very much for these clarifications. I will think about pulling a request.

DejanBukovec commented 1 year ago

There are also other functions ... Check documentation... There is async function: slika slika

Or:

slika

NickCDevel commented 1 year ago

There are also other functions ... Check documentation... There is async function: slika slika

Or:

slika

Thank you very much, I appreciate your help. Unfortunatly none of the ISAPI involving pircam at the exception of those regarding the configuration works for me. I did read the ISAPI for security control doc. I have the impression that some functions should work in pairs (ex: post a request, get the picture) but I didn't find any example on the net, and anyway, I don't know why, all these functions answer me each time: 'Can't locate the url'. I must be missing something, because the pircam works perfectly via hikconnect and access to the image is the main feature I am missing.

Joerivanrokeghem commented 1 year ago

hi @petrleocompel,

first of all, congrats on the nice work! everything is working correctly but my PIR sensors "Wireless Dual-Tech Detector" (DS-PDD12P-EG2-WE(B)) are giving a "wrong" name: '0x00002'. can you change this please? thanks in advance!

home-assistant_hikvision_axpro_2023-07-04T19-00-04.593Z.log

petrleocompel commented 1 year ago

@Joerivanrokeghem fixed in v2.0.0-beta17

r0bb10 commented 1 year ago

I've recently added the DS-PM1-I1-WE input transmitter (to add external contact sensor) https://www.hikvision.com/en/products/Alarm-Products/wireless-intrusion-alarm/ax-pro/ds-pm1-i1-we/ but once added the integration would fail to reload giving this error.

Can it be added (or at least ignored) so that the integration would load correctly?


Logger: homeassistant.config_entries
Source: custom_components/hikvision_axpro/model.py:43
Integration: hikvision_axpro
First occurred: 09:38:05 (1 occurrences)
Last logged: 09:38:05

Error setting up entry AX PRO M2H for hikvision_axpro
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, 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 887, 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 871, in from_dict
    zone = ZoneConfig.from_dict(obj.get("Zone"))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 720, in from_dict
    access_module_type = from_union([AccessModuleType, from_none], obj.get("accessModuleType"))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/model.py", line 43, in from_union
    assert False
AssertionError

<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-30 09:38:05.606 DEBUG (SyncWorker_43) [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-30 09:38:05.624 DEBUG (SyncWorker_43) [custom_components.hikvision_axpro] { "List": [ { "Zone": { "id": 0, "zoneName": "Contatto Porta", "detectorType": "magneticContact", "zoneType": "Delay", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1 ], "enterDelay": 30, "exitDelay": 1, "stayArmDelayTime": 1, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "recover", "timeout": 30, "relateDetector": true, "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0, "linkageCameraName": "" } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 1, 2 ], "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" } }, { "Zone": { "id": 1, "zoneName": "Sensore Living", "detectorType": "indoorDualTechnologyDetector", "zoneType": "Instant", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "recover", "timeout": 30, "relateDetector": true, "detectorSeq": "Q12076044", "RelatedChanList": [ { "RelatedChan": { "relator": "app", "cameraSeq": "", "relatedChan": 0, "linkageCameraName": "" } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 2 ], "alreadyAssociatedZone": [ ], "supportLinkageChannelID": [ ], "alreadyLinkageChannelID": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ ], "linkageZone": [ ], "linkagePIRCAMName": "" }, "armMode": "and", "zoneAttrib": "wireless" } }, { "Zone": { "id": 2, "zoneName": "Test", "detectorType": "other", "zoneType": "Instant", "subSystemNo": 1, "linkageSubSystem": [ 1 ], "supportLinkageSubSystemList": [ 1 ], "enterDelay": 30, "exitDelay": 30, "stayArmDelayTime": 30, "sirenDelayTime": 0, "stayAwayEnabled": false, "chimeEnabled": false, "silentEnabled": false, "chimeWarningType": "single", "timeoutType": "recover", "timeout": 30, "RelatedChanList": [ { "RelatedChan": { "cameraSeq": "", "relatedChan": 0, "linkageCameraName": "" } } ], "doubleKnockEnabled": false, "doubleKnockTime": 5, "CrossZoneCfg": { "isAssociated": false, "supportAssociatedZone": [ 0, 1 ], "alreadyAssociatedZone": [ ], "supportLinkageChannelID": [ ], "alreadyLinkageChannelID": [ ], "associateTime": 1800 }, "newKeyZoneTriggerTypeCfg": "zoneStatus", "zoneStatusCfg": "triggerArm", "armNoBypassEnabled": false, "RelatedPIRCAM": { "supportLinkageZones": [ ], "linkageZone": [ ], "linkagePIRCAMName": "" }, "finalDoorExitEnabled": false, "timeRestartEnabled": false, "armMode": "and", "swingerLimitActivation": 3, "detectorContactMode": "NC", "impulseCountTime": 20, "impulsesBeforeAlarm": 8, "detectorInputMode": "pulse", "detectorTamperMode": "NC", "accessModuleType": "transmitter", "relatedAccessModuleID": 1, "zoneAttrib": "wired" } } ] }
2023-07-30 09:38:05.628 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 390, 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 887, 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 871, in from_dict
zone = ZoneConfig.from_dict(obj.get("Zone"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 720, in from_dict
access_module_type = from_union([AccessModuleType, from_none], obj.get("accessModuleType"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hikvision_axpro/model.py", line 43, in from_union
assert False
AssertionError```
petrleocompel commented 1 year ago

@r0bb10 fixed

r0bb10 commented 1 year ago

@r0bb10 fixed

Perfect, tested and works!

quick debug just to clean up things:

image image

Btw great work as usual!

petrleocompel commented 1 year ago

@r0bb10

Normally we get model from zoneConfig (loaded 1. on start). You can try to provide (enable debug, watch logs for "+ config: " <- this line is the interesting one)
So the "Contatto Porta" is wired. And the system does not report model of wired sensors. Info about this sensor is

{
    "id": 0,
    "zoneName": "Contatto Porta",
    "detectorType": "magneticContact",
    "zoneType": "Delay",
    "subSystemNo": 1,
    "linkageSubSystem": [1],
    "supportLinkageSubSystemList": [1],
    "enterDelay": 30,
    "exitDelay": 1,
    "stayArmDelayTime": 1,
    "sirenDelayTime": 0,
    "stayAwayEnabled": false,
    "chimeEnabled": false,
    "silentEnabled": false,
    "chimeWarningType": "single",
    "timeoutType": "recover",
    "timeout": 30,
    "relateDetector": true,
    "RelatedChanList": [{
        "RelatedChan": {
            "relator": "app",
            "cameraSeq": "",
            "relatedChan": 0,
            "linkageCameraName": ""
        }
    }],
    "doubleKnockEnabled": false,
    "doubleKnockTime": 5,
    "CrossZoneCfg": {
        "isAssociated": false,
        "supportAssociatedZone": [1, 2],
        "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"
}

So I do not think it is possible. Also for wired sensors it is not real to report anything. You can wire anything to these contact. Custom made stuff, different brands wired sensors, magnetic, PIR, etc...

The naming scheme with "zone / channel" maybe. But you have the name and reality is .. that the sensor is unknown.

Joerivanrokeghem commented 1 year ago

Hi @petrleocompel

can u add 0x00031 to the integration please? it is the DS-PDCO-E-WE Wireless CO Detector. thanks!

home-assistant_hikvision_axpro_2023-07-31T15-54-32.545Z.log

petrleocompel commented 1 year ago

@Joerivanrokeghem I quickly added the model to be recognized but I kinda do not know how to get info from that device.

I do not know what happens when it would be triggered. What attribute would changed. Keep in mind there is the "timeout of sync" with HA (see in configuration) the trigger does not have to be immediate but it is about sync interval.

Joerivanrokeghem commented 1 year ago

hi petr,

I updated to v2.0.2 and restarted the integration/ HA but the model is still displayed as 0x00031. when I have the time I will test what attribute will change. but I think it will be the same attributes as by the smoke detectors.

petrleocompel commented 1 year ago

@Joerivanrokeghem - fixed it in release v2.0.3 I overlooked the number