SmartThings virtual devices using CLI

Sure, but I should add the disclaimer that there has been no obvious attempt to launch these devices yet and they may not even be ready for us to play with. As the devices are based on capabilities, unless there is a setter or enum command defined in said capabilities there is as yet no way to use them in Routines, Scenes and Rules. Instead you use an API command to specify events, rather like you would with a SmartApp based device. It is clear that the virtual devices will support either local or cloud at some stage, and it is possible that this might involve Edge drivers for the local ones. I simply don’t know. The custom virtual devices seem to have some kind of command mapping feature to come. I don’t know what that is. That said, if you want to create a cloud based virtual switch , this is what the CLI does (tarted up a bit for readability):

URL:  https://api.smartthings.com/virtualdevices/prototypes
Body: { "name": "{{Label for the device}}",
        "roomId": "{{Room ID}}",
        "prototype": "VIRTUAL_SWITCH",
        "owner": {
          "ownerType": "LOCATION",
          "ownerId": "{{Location ID}}"
        }
      }

As it is a switch it has on and off commands that do the obvious thing. However just to show how it works for other virtual devices, this is how the switch could be turned off:

URL:  https://api.smartthings.com/virtualdevices/{{Device ID}}/events
Body: { "deviceEvents: [
          { "component": "main",
            "capability":"switch",
            "attribute": "switch",
            "value": "off"
          }
        ]
      }

I don’t know what the deal is with the ‘state change’ value on these devices. I think it may default to on, at least for the switch. I don’t know if there is a way to turn it off.

I am not recommending to anyone to do any of the above. I am just a reporter. I didn’t uncork the bottle.

2 Likes