Integration with hikvision ax pro alarm system

Anyone know how to arm an area using ISAPI?

or how to get a sensor state?

Hi Dariush,

Did you ever come right with adding ax pro to home assistant?

Hi, I’ve tried quickly sniffing the network calls vs the hub, didn’t succeed.
If you’re interested, we could give a try wirking together after vacation.
Let me know, ciao, Dariush

Hi Dariush, what methods were you using to sniff? I have started looking at this myself. There is definitely some work to be done in this. I would definitely wish to help or participate. I came across this repo, might be a useful starting point in order to communicate with the hub programmatically.

Hi, I managed to make my AxHub working with HA, ISAPI should be the same for AxPro:

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"] }}'
 
switch:
  - platform: command_line
    switches:
      ax_arm_home:
            command_on: "/usr/bin/curl -X PUT --digest -u user:password 'http://<ip>/ISAPI/SecurityCP/control/arm/1?ways=stay&format=json'"
      ax_arm_away:
            command_on: "/usr/bin/curl -X PUT --digest -u user:password 'http://<ip>/ISAPI/SecurityCP/control/arm/1?ways=away&format=json'"
      ax_disarm:
            command_on: "/usr/bin/curl -X PUT --digest -u user:password 'http://<ip>/ISAPI/SecurityCP/control/disarm/1?format=json'"

If you setup a manual alarm_control_panel it will also work with Homekit:

alarm_control_panel:
  - platform: template
    panels:
      allarme:
        name: AxHub
        value_template: >-
            {%- if is_state('sensor.axhubpanel', 'disarm') %}
              disarmed
            {% else %}
              {%- if is_state('sensor.axhubpanel', 'stay') %}
                armed_home
              {% else %}
                {%- if is_state('sensor.axhubpanel', 'away') %}
                    armed_away
                {% else %}
                    unavailable
                {% endif %}
              {% endif %}
            {% endif %}
        arm_home:
            service: script.ax_arm_stay
        arm_away:
            service: script.ax_arm_away
        disarm:
            service: script.ax_disarm

Ciao!

4 Likes

For anyone that’s interested, I got it working with the ax pro hub yesterday! It works differently to the older axhub in that it needs more than just digest auth. I wrote it in typescript for node, but being a home-assistant newbie, was wondering what the best way is to integrate this with ha is? any ideas let me know!
Repo is emmetdel/hikvision-api (github.com).Comments are welcome as code is still in a very early stage.

I’m getting 401 after checking user/password are correct despite using digest… any ideas?

hikvision-toolkit/.jest.setup.js at b2cece9bb76b51a37dd3f514977ad122188ee0d7 · emmetdel/hikvision-toolkit · GitHub

I hope those are test credentials!

Uhmm… which FW version are you on? My panel is on 1.07.
Ax-PRO or AxHub?

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