Integration with hikvision ax pro alarm system

I’m on AX Pro DS-PWA64-L-WE running V1.2.4 build 210629 firmware.

Using Google Chrome, I can see on the network tab the following request

However, if I try:

curl -i --digest -u username:password GET "http://<IP>/ISAPI/SecurityCP/Configuration/capabilities?format=json" 

I get:

curl: (6) Could not resolve host: GET
HTTP/1.1 401 Unauthorized
Date: Thu, 26 Aug 2021 09:49:08 GMT
Server: Webs
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
Content-Length: 138
Content-Type: application/xml; charset="UTF-8"
Connection: keep-alive
Keep-Alive: timeout=60, max=99
XXXXXXXXXXXXXXXXX

HTTP/1.1 401 Unauthorized
Date: Thu, 26 Aug 2021 09:49:08 GMT
Server: Webs
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
Content-Length: 231
Content-Type: application/xml; charset="UTF-8"
Connection: keep-alive
Keep-Alive: timeout=60, max=98
XXXXXXXXXXXXXXXXX

<?xml version="1.0" encoding="UTF-8" ?>
<userCheck>
<statusValue>401</statusValue>
<statusString>Unauthorized</statusString>
<lockStatus>unlock</lockStatus>
<unlockTime>0</unlockTime>
<retryLoginTime>6</retryLoginTime>
</userCheck>

I’ve checked to ensure the account hasn’t been blocked. I can log in fine.

Seems like a there’s a problem in the CURL syntax:

curl: (6) Could not resolve host: GET

If you are trying from console, try adding “-X” before the request method:

curl -i --digest -u username:password -X GET "http://<IP>/ISAPI/SecurityCP/Configuration/capabilities?format=json" 

However I suggest using the “Talend API Tester” extension for Chrome, so you can test these calls through the browser in a simple way.

I can get responses after authenticating via the web interface and then using Talend so I must be doing something wrong when authenticating. Any ideas? I’m almost there! :slight_smile:

Which command are you using and which error you get?

Thanks for your continued support.

If I authenticate via the web browser:

Then try a command from Talend, I can see the states:

The JSON should match up to what is returned with your code:

sensor:
  - platform: rest
    name: axhubsys
    resource: http://<ip>/ISAPI/SecurityCP/status/subSystems?format=json
    username: xxxxx
    password: yyyyy
    authentication: digest
    value_template: 'OK'
    scan_interval: 10
    json_attributes:
        - SubSysList
  - platform: template
    sensors:
       axhubpanel:
        friendly_name: "AxHub Panel"
        value_template: '{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["arming"] }}'
        attribute_templates:
            id: '{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["id"] }}'
            arming: '{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["arming"] }}'
            alarm: '{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["alarm"] }}'

However when I test it in HA I get the following:

image

It must be something to do with authentication, the details I enter are the same as I enter when logging in via the web interface.

Ok, step back: are you getting correct attributes for sensor.axhubsys in the “developer tools”?
Here is mine:

No, this is all I get
Untitled

Ok, if you reboot HA and take a look at the log, I think you should find some errors about sensor.axhubsys during startup… What are those errors reporting?

Hello everyone,
I own the same alarm and I receive the following error in the log:

  • TemplateError(‘UndefinedError: None has no element 0’) while processing template ‘Template("{{ state_attr(“sensor.axhubsys”, “SubSysList”)[0][“SubSys”][“arming”] }}")’ for attribute ‘_attr_native_value’ in entity ‘sensor.axhubpanel’

Thanks

You should look at the status of the sensor.axhubsys sensor, that should be like this

This is the error in log:

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:73
Integration: Template (documentation, issues)
First occurred: 11:13:41 (4 occurrences)
Last logged: 11:13:41

TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr('sensor.axhubsys', 'SubSysList')[0]['SubSys']['arming'] }}")' for attribute '_attr_native_value' in entity 'sensor.axhubpanel'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr('sensor.axhubsys', 'SubSysList')[0]['SubSys']['arming'] }}")' for attribute 'arming' in entity 'sensor.axhubpanel'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr('sensor.axhubsys', 'SubSysList')[0]['SubSys']['id'] }}")' for attribute 'id' in entity 'sensor.axhubpanel'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr('sensor.axhubsys', 'SubSysList')[0]['SubSys']['alarm'] }}")' for attribute 'alarm' in entity 'sensor.axhubpanel'
1 Like

Where is script.ax_arm_stay and others.
Is it work if we use the switch entity on the service ?.
Please provide the script section too.
I am beginner. apology for the silly questions.

Hi, I created scripts for the only purpose of resetting the arm/disarm switches off, after executing the operation:

alias: ax_arm_stay
sequence:
  - service: switch.turn_on
    target:
      entity_id: switch.ax_arm_home
  - service: switch.turn_off
    target:
      entity_id: switch.ax_arm_home
mode: single

Alternatively, you could create an automation, triggered by switch.ax_arm_home changing to ON, that sets it OFF after a second

1 Like

Hello,

Looks like your repo has been removed, could you repost the code please? I’m trying to achieve the same thing, adding my AX Pro setup to HA. Thanks.

Hi,

Looks like it doesn’t work the same way for AX PRO systems, too bad! But still thanks for the info. I think Emmet has some key information because he states “It works differently to the older axhub in that it needs more than just digest auth” but no more responses from him… @emmetdel care to join in again?

As other state, we tried your sensor code but when using developer tools and read the status of the sensor, we only get “friendly_name: axhubsys” and nothing more. In the logs we get:

Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:140
Integration: Template ([documentation](https://www.home-assistant.io/integrations/template), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+template%22))
First occurred: 08:54:15 (4 occurrences)
Last logged: 08:54:15

* TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["arming"] }}")' for attribute '_attr_native_value' in entity 'sensor.axhubpanel'
* TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["arming"] }}")' for attribute 'arming' in entity 'sensor.axhubpanel'
* TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["id"] }}")' for attribute 'id' in entity 'sensor.axhubpanel'
* TemplateError('UndefinedError: None has no element 0') while processing template 'Template("{{ state_attr("sensor.axhubsys", "SubSysList")[0]["SubSys"]["alarm"] }}")' for attribute 'alarm' in entity 'sensor.axhubpanel'

EDIT:

I changed the code by removing the “value_template” attribute, this way I can see what goes wrong:

sensor:
  - platform: rest
    name: axhubsys
    resource: http://<ip>/ISAPI/SecurityCP/status/subSystems?format=json
    username: xxxxx
    password: yyyyy
    authentication: digest
    scan_interval: 10
    json_attributes:
        - SubSysList

This gives me in the developer tools: {“userCheck”: {“statusValue”: “401”, “statusString”: “Unauthorized”}}

I tried to create an operator user in the AX PRO hub but same result. Tried with admin, same result. But if I put http://ip/ISAPI/SecurityCP/status/subSystems?format=json in my browser, it works fine… But not from HA.

do you still got it working… ? any update?

1 Like

I hope this gets attention as I’m looking to install ax pro at my place soon. Already have cameras that I’d like to get integrated aswell

Hello. I so assume that you need to get an ID session. like here https://community.home-assistant.io/t/ds-kd8003-ds-kv8113-ds-kv8213-ds-kv6113-ds-kv8413-and-integration-hikvision-hikconnect-video-intercom-doorbell/ 238535/1133

if i log in to the axpro in my webbrowser and then test the sensor in developer it works but without login in i get 401 error. so it seems lite its the auth metod digest or basic that dont work, in hikvision kameras you kan change the auth metod but not in the alarm… so i think thats the problem but i cant find out what.
btw the axpro block the ip on my HA even if its the right user and password.