Hello Everyone,
I am trying to use the RESTful platform to fetch data from a Hikvision Access Control Terminal DS-K1T805MBFWX (a fingerprint reader and keypad). Data is collected fine the first time it is polled (upon restart or after “rest entities” reload is performed). However, from the moment the scan_interval is reached the first time and until it is reloaded manually again, attributes dissapear and do not load again unless I reload REST.
Should I do anything to fix this or isn’t the rest platform the right choice for this kind of sensor data fetching?
rest:
- authentication: digest
username: "admin"
password: "xxxxxx"
scan_interval: 10
resource: http://192.168.0.75/ISAPI/AccessControl/AcsEvent?format=json
method: POST
headers:
Content-Type: "application/json"
payload: >-
{"AcsEventCond": {"searchID": "1","searchResultPosition": 0,"maxResults": 10,"major": 0,"minor": 0,"startTime": "2025-04-17T00:00:00+02:00","endTime": "2035-04-18T23:59:59+02:00","timeReverseOrder": true}}
sensor:
- name: "HikReader"
json_attributes_path: "$.AcsEvent.InfoList[0]"
value_template: "HikReader"
json_attributes:
- "major"
- "minor"
- "time"
- "type"
- "serialNo"
- "netUser"
- "remoteHostAddr"
- "cardType"
- "name"
- "cardReaderNo"
- "doorNo"
- "employeeNoString"
- "userType"
- "currentVerifyMode"
sensor data upon first polling:
sensor data after second scan:
Error in core logs:
Logger: homeassistant.components.rest.util
Source: components/rest/util.py:33
integration: RESTful (documentation, issues)
First occurred: 8:23:38 PM (430 occurrences)
Last logged: 9:36:34 PM
JSON result was not a dictionary or list with 0th element a dictionary
If I use a command_line sensor instead for one of the JSON values, sensor data stays fine as it should:
command_line:
- sensor:
command: !secret HikReader_Events
name: "HikReader Time"
scan_interval: 5
value_template: >
{{ value_json.AcsEvent.InfoList[0].time if value_json.AcsEvent.InfoList | length > 2 and 'time' in value_json.AcsEvent.InfoList[0] else 'Desconocido' }}
Secret:
curl --digest -k -u admin:xxxxxx --location 'http://192.168.0.75/ISAPI/AccessControl/AcsEvent?format=json' --header 'Content-Type: application/json' --data '{"AcsEventCond": {"searchID": "1","searchResultPosition": 0,"maxResults": 10,"major": 0,"minor": 0,"startTime": "2025-04-17T00:00:00+02:00","endTime": "2035-04-18T23:59:59+02:00","timeReverseOrder": true}}'
But, I’d rather use the REST platform because I can collect several JSON values as attributes in one single sensor easily, so happy to get some advice if possible. Thanks!