Hi forum, I was checking REST API doc and it looks like plugins are not exposed in REST API. Am I right? I can see plugin settings but not actions. I installed USB Relay Control plugin and want to trigger relays via MQTT as well (MQTT subscriber call REST API in the background). If there is no REST API integration out off the box for plugins can I update plugin code myself to integrate it with REST?
It's up to the individual plugin authors if they want to add an API to their plugin, and then if they want to document it as well. Adding APIs to the code is the only way if it doesn't already exist.
This plugin does utilize API here, it's just not documented. So the post commands available are turnUSBRelayOn, turnUSBRelayOff, and getUSBRelayState all of which expect an id parameter as well. A simple get request to /api/plugin/usbrelaycontrol would return current state for all if I'm reading the code correct.
Thanks to your post I was able to consume the API. Maybe it will be useful for someone else:
Method is POST:
URI: http://octoUrl/api/plugin/usbrelaycontrol?apikey=XXX
If you want to turn off one off the relays put in Request body:
{
"command":"turnUSBRelayOff",
"id":"1"
}
If you want to turn on one off the relays put in Request body:
{
"command":"turnUSBRelayOn",
"id":"1"
}
Relay ids starts from 0!
Regards