Hi,
I have a RESTful sensor connected to the Domotz Public API. When querying for the internet speed, the reply is an array of the measurements of the last 7 days (see below for an example). I need to get the last element from that array, can I do this in a template? There is no way to be sure in advance how many measurements will be sent through.
The api call does have a way to time-limit the responses to less than 7 days, but that would require me to use a template in the resource:
part of the sensor, which does not seem to be possible.
Additional issue: the reply is likely to be longer than 255 characters, so I need to pass this through json_attributes
, but I don’t know how to do this as there is no named object at the top level.
Sample of the array:
[
{
"timestamp": "2019-04-05T19:20:58+00:00",
"values": [
186969402,
19004487
]
},
{
"timestamp": "2019-04-05T20:39:29+00:00",
"values": [
180379702,
18999822
]
},
{
"timestamp": "2019-04-05T21:59:37+00:00",
"values": [
175382534,
19045850
]
},
{
"timestamp": "2019-04-06T02:39:29+00:00",
"values": [
189920953,
19108310
]
},
{
"timestamp": "2019-04-06T08:39:31+00:00",
"values": [
188248922,
19089989
]
}
]