I'm trying to use the new maker API; I have a virtual presence device, and I can see it listed by the app:
[ {
...
"type": "Virtual Presence",
"id": "613",
...
"capabilities": [
"PresenceSensor",
"Sensor"
],
"attributes": {
"presence": "present"
},
"commands": [ {
"command": "arrived"
},
{
"command": "departed"
} ] } ]
But trying to invoke a command...
apps/api/579/devices/613/departed?access_token=...
...logs this error (which is an error inside the error, I would say):
2018-10-04 14:03:52.900:errorgroovy.lang.MissingMethodException: No signature of method: hubitatMakerAPI.httpError() is applicable for argument types: (java.lang.Integer, java.lang.String) values: [404, Command not found] (sendDeviceCommand)
2018-10-04 14:03:52.851:debugfindDevice called
2018-10-04 14:03:52.849:debugsendDeviceCommand called
What am I doing wrong?
There is a white list of commands for devices. "Departed" and "Arrived" are not in the whitelist. Will look at adding these to the whitelist in an upcoming release.
OK; whitelisting (especially with no way to control it on the user's side) seems to be an odd choice in this case... maybe blacklisting would be a more reasonable approach here.
Anyway, thanks.
Appreciate the feedback, we chose a whitelist because the list of custom commands is infinite that could potentially be called. This is meant to be a simple API to control basic functionality via HTTP GET methods only.
I'm sure we will find other commands that need to be added to the whitelist for different use cases, but we wanted to make sure we only allow a smaller subset of commands typically used for devices and not allow any and all command be sent to any device.
I'm not sure how this works on the backend but I have a few custom drivers with attributes I would love to set with an arduino sending an http request.. I noticed most commands do not work.. One that I was really shocked wouldn't work was the virtual motion sensor active and inactive commands
I did work around the motion by changing my virtual device to a switch rather than motion sensor
Sensor commands were not whitelisted because a normal device can not be updated. The device does not typically allow its state to be updated. However, you bring up a good point regarding virtual devices. We will take a look at the virtual devices and what commands they expose and look at what might also need to be updated.
1 Like