Adding A Remote Sensor
I've been tinkering with the API and I got curious if I could add a remote sensor. I got pretty close, so I am wondering if anyone else has gotten it to work.
Here is cURL code that seems to create it (snipet from sh script):
new_remote_sensor='{
"data": {
"type": "remote-sensors",
"attributes": {
"name" : "test"
},
"id": "12345678-0301-0101-0101-123456789abd"
}
}'
curl --verbose --header "Content-type: application/json" --header "Authorization: Bearer $token" "$endpoint/api/remote-sensors" --request POST --data-raw "$new_remote_sensor"
Then I get response 201 indicating that a new resource has been created and the following response body:
{
"meta": {
"self": "/api/remote-sensors"
},
"data": {
"type": "remote-sensors",
"id": "12345678-0301-0101-0101-123456789abd",
"relationships": {
"sensor-readings": {
"links": {
"related": "/api/remote-sensors/12345678-0301-0101-0101-123456789abd/sensor-readings"
}
},
"structure": {
"links": {
"related": "/api/remote-sensors/12345678-0301-0101-0101-123456789abd/structure"
},
"data": null
},
"room": {
"links": {
"self": "/api/remote-sensors/12345678-0301-0101-0101-123456789abd/relationships/room",
"related": "/api/remote-sensors/12345678-0301-0101-0101-123456789abd/room"
},
"data": {
"type": "rooms",
"id": null
}
}
},
"attributes": {
"ignore-readings-for-room": false,
"name": "test",
"is-tstat": false,
"sensor-type": null
}
}
}
But, unfortunately when I try to query the sensor I get a fail:
curl --verbose --header "Content-type: application/json" --header "Authorization: Bearer $token" "$endpoint/api/remote-sensors/12345678-0301-0101-0101-12345678abd" --request GET
< HTTP/2 500
< date: Fri, 11 Mar 2022 22:44:41 GMT
< content-type: text/html
< content-length: 141
<
<html>
<head>
<title>Internal Server Error</title>
</head>
<body>
<h1><p>Internal Server Error</p></h1>
</body>
</html>
Also when I query remote sensors I get a response without anything in the "data" field. Indicating that the remote sensor did not get really created:
curl --verbose --header "Authorization: Bearer $token" "$endpoint/api/remote-sensors"
{
"data": [],
"meta": {
"self": "/api/remote-sensors",
"first": "/api/remote-sensors?include=&page%5Bsize%5D=50&page%5Bpage%5D=1",
"last": "/api/remote-sensors?include=&page%5Bsize%5D=50&page%5Bpage%5D=0",
"next": null,
"prev": null
}
}
Any ideas?
Thanks,
Jose
-
Official comment
This question has been answered via a Support Ticket.
Flair allows control of objects that have already been added via the Flair app. If you're looking to add devices via the API, please first add them via app Setup, and then they will be available via the API.
All the best,
Finn
Comment actions -
So just to make sure everything is clear here... This has NOT been answered by Support Ticket, per se. A rep who was an intermediary and not an actually technical person contacted me about this. After a few days of back and forth, where she had to contact an engineer and wait for an answer to have me try different things, the engineers finally responded that it cannot be done.
If the answer was that it could not be done in the first place, why the week long back and forth? "Finn" above even contradicts himself in the note he wrote, "if you are looking to add devices via the API, add them first via the App...". Obviously that makes no sense. Perhaps he meant ,"if you are looking to CONTROL devices via the API..."
The bottom line is that it cannot be done with the API. At least not in any what that is documented. Hopefully the API will be enhanced in the future.
Jose
Regards,
Jose
Please sign in to leave a comment.
Comments
3 comments