Hi all
I’m trying to connect to a REST endpoint. That in itself is not that difficult. I’ve got the following:
#ALARM
- platform: rest
name: ClimaxSensor
resource: 'http://172.16.1.19/action/deviceListGet'
authentication: basic
username: !secret climax_user
password: !secret climax_pass
value_template: '{{ value_json.senrows }}'
json_attributes:
- senrows
- platform: template
sensors:
cs_status1:
friendly_name: "Entrevindue"
# value_template: '{{states.sensor.climaxsensor[0][3]["status"]}}'
value_template: >
{{ state_attr('sensor.climaxsensor', 'senrows')[3]['status']}}
cs_status2:
friendly_name: "Peter vindue"
value_template: '{{states.sensor.climaxsensor.senrows[4]["status"]}}'
But the returned JSON is for longer than the 255 char limit: (refer to bottom code block).
Question: how do I access the lot? I’ve figured that I cannot create jsonpath expressions against the JSON with a filter (eg. [?(@name==“Marie vindue”)] <-- I cannot make that work.
I figured I need something like senrows in the json_attributes
attribute in the sensor declaration… but that does not do the trick for me… Can anybody help how to access the array? I’ve tried for several days, but I cannot find out how to do it…
Thanks in advance
{
"senrows": [
{
"area": 1,
"zone": 15,
"type": 27,
"type_f": "IR Camera",
"name": "Alrum foto",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "",
"id": "XXXXX593530",
"su": 1
},
{
"area": 1,
"zone": 2,
"type": 37,
"type_f": "Keypad",
"name": "Bryggers",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "",
"id": "XXXXXdb5170",
"su": 0
},
{
"area": 1,
"zone": 1,
"type": 37,
"type_f": "Keypad",
"name": "Entre",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Good, 5",
"status": "",
"id": "XXXXXdb7470",
"su": 0
},
{
"area": 1,
"zone": 7,
"type": 4,
"type_f": "Door Contact",
"name": "Entrevindue",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Good, 4",
"status": "Door Close",
"id": "XXXXX75cd10",
"su": 1
},
{
"area": 1,
"zone": 13,
"type": 4,
"type_f": "Door Contact",
"name": "Peter vindue",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX75ce10",
"su": 1
},
{
"area": 1,
"zone": 6,
"type": 4,
"type_f": "Door Contact",
"name": "Alrumd\u00f8r trp",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 8",
"status": "Door Close",
"id": "XXXXX75d210",
"su": 1
},
{
"area": 1,
"zone": 3,
"type": 4,
"type_f": "Door Contact",
"name": "Bryggersd\u00f8r",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX75e310",
"su": 1
},
{
"area": 1,
"zone": 4,
"type": 4,
"type_f": "Door Contact",
"name": "Bryggersvindue",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX75fd10",
"su": 1
},
{
"area": 1,
"zone": 8,
"type": 4,
"type_f": "Door Contact",
"name": "Entred\u00f8r",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 6",
"status": "Door Close",
"id": "XXXXX762810",
"su": 1
},
{
"area": 1,
"zone": 14,
"type": 4,
"type_f": "Door Contact",
"name": "Badv\u00e6relse",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX763910",
"su": 1
},
{
"area": 1,
"zone": 11,
"type": 4,
"type_f": "Door Contact",
"name": "Alrumd\u00f8r",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 7",
"status": "Door Close",
"id": "XXXXX764710",
"su": 1
},
{
"area": 1,
"zone": 5,
"type": 4,
"type_f": "Door Contact",
"name": "K\u00f8kkend\u00f8r",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX764910",
"su": 1
},
{
"area": 1,
"zone": 12,
"type": 4,
"type_f": "Door Contact",
"name": "Peter terrasse",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 9",
"status": "Door Close",
"id": "XXXXX765b10",
"su": 1
},
{
"area": 1,
"zone": 9,
"type": 4,
"type_f": "Door Contact",
"name": "Marie vindue",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 8",
"status": "Door Close",
"id": "XXXXX765e10",
"su": 1
},
{
"area": 1,
"zone": 10,
"type": 4,
"type_f": "Door Contact",
"name": "Marie terrassed\u00f8r",
"cond": "",
"cond_ok": "1",
"battery": "",
"battery_ok": "1",
"tamper": "",
"tamper_ok": "1",
"bypass": "No",
"temp_bypass": "0",
"rssi": "Strong, 8",
"status": "Door Close",
"id": "XXXXX9b7110",
"su": 1
}
]
}