Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional devices and functions #14

Open
DejanBukovec opened this issue Feb 28, 2023 · 50 comments
Open

Add support for additional devices and functions #14

DejanBukovec opened this issue Feb 28, 2023 · 50 comments
Assignees
Labels
enhancement New feature or request

Comments

@DejanBukovec
Copy link

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
Copy link
Owner

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 petrleocompel self-assigned this Feb 28, 2023
@petrleocompel petrleocompel added the enhancement New feature or request label Feb 28, 2023
@petrleocompel
Copy link
Owner

I added endpoints to hikaxpro (fork) waiting for some pull requests
petrleocompel/hikaxpro@955a66c

@DejanBukovec
Copy link
Author

Thanks will wait for pull :)

@leciuk81
Copy link

leciuk81 commented Mar 2, 2023

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
Copy link
Author

DejanBukovec commented Mar 2, 2023

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
Copy link
Owner

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
Copy link

leciuk81 commented Mar 2, 2023

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:

  • DS-PS1-E-WE
  • DS-PT1-WE
  • DS-PS1-I-WE
  • DS-PDPG12P-EG2-WE
  • DS-PDPC12P-EG2-WE
  • DS-PDP15P-EG2-WE
    In addition to the door sensors, I also connected additional wired contacts to the 2 auxiliary contacts which are recognized in HA but there is no magnet trigger. I show you below what is displayed:

image

I'm available if you need debug just tell me

@DejanBukovec
Copy link
Author

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
Copy link
Owner

@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
Copy link
Author

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
Copy link
Owner

@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
Copy link

leciuk81 commented Mar 2, 2023

@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
Copy link
Owner

petrleocompel commented Mar 2, 2023

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
Copy link

leciuk81 commented Mar 2, 2023

However, it is recognized with diagnostics but without a trigger

image

image

@petrleocompel
Copy link
Owner

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
Copy link

leciuk81 commented Mar 2, 2023

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

@DejanBukovec
Copy link
Author

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
Copy link
Owner

@DejanBukovec behaviour should be:

  • alarm off
  • arm system
  • armed = true
  • Sensor trigger
  • sensor - alarm = true
  • system - alarm
  • system - disarm
  • sensor - alarm = false

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:

  • I don't have the knowledge - in HA nor AX Pro, but can figure it out. On HA it is registration of webhooks and schema implementation in integration, on AX Pro it is just URL set up (we could do it as configuration step - auto config if you provide admin user or do it yourself)
  • Maybe then integration should be little bit redesigned - how things works

@leciuk81
Copy link

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
Copy link
Owner

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
Copy link

@petrleocompel
Copy link
Owner

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
Copy link

image

@leciuk81
Copy link

leciuk81 commented Mar 12, 2023

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
Copy link
Owner

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

In your log Zona cablata 22 is detectorType other so no info provided. 😞
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.

This was referenced Mar 29, 2023
@petrleocompel
Copy link
Owner

@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.

  • AXHub login support
  • Arm / disarm of zones

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
Copy link

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
Copy link
Author

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
Copy link
Owner

@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
Copy link

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
Copy link

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
Copy link
Author

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

Or:

slika

@NickCDevel
Copy link

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
Copy link

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
Copy link
Owner

@Joerivanrokeghem fixed in v2.0.0-beta17

@r0bb10
Copy link

r0bb10 commented Jul 30, 2023

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
Copy link
Owner

@r0bb10 fixed

@r0bb10
Copy link

r0bb10 commented Jul 31, 2023

@r0bb10 fixed

Perfect, tested and works!

quick debug just to clean up things:

image
image

  • the manufacturer colums should all report "HikVision" but actually the axpro is reported as "Hikvision - Ax Pro" (basically should all report like the last one in the first screenshot, the dualtech sensor one), and so all the sensors that are "Unknown".
  • the model should correctly report the actual model not the friendly name, so i think that instead of dualtech sensor it should report "DS-PDD12P-EG2-WE"
  • my contact sensor is wired to to the M2H on channel 1 (AKA Zone 1), since there is no actual model for this one i think the best way to remove "unknown" it should report the DS-PWA96-M2H-WE name and maybe the zone number, so "DS-PWA96-M2H-WE Z1" or something similar (the M2H has 16 total wired zones onboard).

Btw great work as usual!

@petrleocompel
Copy link
Owner

@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
Copy link

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
Copy link
Owner

@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
Copy link

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants