01304 827609 info@use-ip.co.uk Find us

DS-K1T805MBFWX and DS-KV6113-WPE1

Perhaps a bit off-topic because the following is more for the HASS forum, but I think it could be fine to continue this topic here.

I already built a rest sensor in Home Assistant that "works" when it is polled the first time. However, after the second poll, the sensor seems to not be able to fetch data and the following error is logged in the core:

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

This is my sensor:

rest:
- authentication: digest
username: "admin"
password: "xxxxx"
scan_interval: 10
resource: http://192.168.0.75/ISAPI/AccessControl/AcsEvent?format=json
method: POST
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"

There is not any connectivity problem with the device. Actually, everytime I reload the REST ENTITIES, data is displayed fine. However, after the 10 seconds scan_interval is reached, sensor attributes dissapear. No issues if I reload manually in postman several times:

BEFORE

before.png


AFTER

after.png


Any clue of what it is happening? If not, next step will be to try to build this with a cURL command instead and parse response accordingly, but I thought this REST route would be "cleaner", as I would have all data as attributes in a single sensor.
 
Http listener is best option for real time thats what i use, the crud what i shown you in my project is being used for syncing. For example if HA was off, then on first start will sync events and co tinue off with listener.
 
Back
Top