The answer is almost certainly yes, but the steps rather depend on the nature of the ‘virtual device’ and how you want to do it.
For example you could create a virtual device using the SmartThings CLI tool to create a device profile (smartthings deviceprofiles:create
) with the capabilities relativeHumidityMeasurement
, temperatureMeasurement
and carbonDioxideMeasurement
and then using that profile in smartthings virtualdevices:create
to create a device. Like this one …
smartthings devices:status 3c374979-f3bf-4250-b177-c514161efae7
─────────────────────────────────────────────────────────────────────────────────
Capability Attribute Value
relativeHumidityMeasurement humidity 4.360262491785161 %
temperatureMeasurement temperatureRange {
"maximum": 2028.9512493247526,
"step": 4268.191013300918,
"minimum": 6230.791732339365
} F
temperatureMeasurement temperature 4172.907975609753 F
carbonDioxideMeasurement carbonDioxide 146828.37852645424 ppm
─────────────────────────────────────────────────────────────────────────────────
Now all of those capabilities are pure sensors, so they don’t have any commands that can be used to set the attributes. So instead we have to create the events for them.
> smartthings virtualdevices:events 3c374979-f3bf-4250-b177-c514161efae7
────────────────────────────────
# Id
────────────────────────────────
1 carbonDioxideMeasurement
2 relativeHumidityMeasurement
3 temperatureMeasurement
────────────────────────────────
? Select a capability. 1
? Enter 'carbonDioxide' attribute value: 1000
──────────────────────────────────────────────────────────────────────────
Component Capability Attribute Value State Change?
main carbonDioxideMeasurement carbonDioxide 1000 undefined
──────────────────────────────────────────────────────────────────────────
> smartthings virtualdevices:events 3c374979-f3bf-4250-b177-c514161efae7
────────────────────────────────
# Id
────────────────────────────────
1 carbonDioxideMeasurement
2 relativeHumidityMeasurement
3 temperatureMeasurement
────────────────────────────────
? Select a capability. 2
? Enter 'humidity' attribute value: 76
─────────────────────────────────────────────────────────────────────────
Component Capability Attribute Value State Change?
main relativeHumidityMeasurement humidity 76 undefined
─────────────────────────────────────────────────────────────────────────
> smartthings virtualdevices:events 3c374979-f3bf-4250-b177-c514161efae7
────────────────────────────────
# Id
────────────────────────────────
1 carbonDioxideMeasurement
2 relativeHumidityMeasurement
3 temperatureMeasurement
────────────────────────────────
? Select a capability. 3
─────────────────────
# Attribute Name
─────────────────────
1 temperature
2 temperatureRange
─────────────────────
? Select an attribute. 1
? Enter 'temperature' attribute value: 40
─────────
# Unit
─────────
1 C
2 F
─────────
? Select a unit. 1
──────────────────────────────────────────────────────────────────────
Component Capability Attribute Value State Change?
main temperatureMeasurement temperature 40 undefined
──────────────────────────────────────────────────────────────────────
> smartthings devices:status 3c374979-f3bf-4250-b177-c514161efae7
─────────────────────────────────────────────────────────────────────────────────
Capability Attribute Value
relativeHumidityMeasurement humidity 76 %
temperatureMeasurement temperatureRange {
"maximum": 2028.9512493247526,
"step": 4268.191013300918,
"minimum": 6230.791732339365
} F
temperatureMeasurement temperature 40 C
carbonDioxideMeasurement carbonDioxide 1000 ppm
─────────────────────────────────────────────────────────────────────────────────
I suppose I ought to do this with the temperature range as well. Just to make it more interesting, let’s turn on the debugging and do the whole lot on one line (this is on Windows).
> set SMARTTHINGS_DEBUG=true
> smartthings virtualdevices:events 3c374979-f3bf-4250-b177-c514161efae7 temperatureMeasurement:temperatureRange "{ ""maximum"":100, ""step"":5, ""minimum"": 0 }"
[2024-03-16T17:08:09.986] [DEBUG] login-authenticator - authentication - enter
[2024-03-16T17:08:09.991] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/capabilities/temperatureMeasurement/1","method":"get","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.8.1 win32-x64 node-v18.5.0","Accept-Language":"en-GB","Authorization":"Bearer aac1f59e-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}}
[2024-03-16T17:08:10.275] [DEBUG] login-authenticator - authentication - enter
[2024-03-16T17:08:10.276] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/virtualdevices/3c374979-f3bf-4250-b177-c514161efae7/events","method":"post","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.8.1 win32-x64 node-v18.5.0","Accept-Language":"en-GB","Authorization":"Bearer aac1f59e-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},"data":{"deviceEvents":[{"component":"main","capability":"temperatureMeasurement","attribute":"temperatureRange","value":{"maximum":100,"step":5,"minimum":0}}]}}
──────────────────────────────────────────────────────────────────────────────────────────────────────────
Component Capability Attribute Value State Change?
main temperatureMeasurement temperatureRange {"maximum":100,"step":5,"minimum":0} undefined
──────────────────────────────────────────────────────────────────────────────────────────────────────────
There you can see the details of the API request that is being made behind the scenes so you can do it any way you like.
So I think that is probably the ‘yes’ dealt with, though not necessarily the steps you need.