Laptop state check with Smartthings

Just to add a bit more…

If you want to control an action on the PC/Laptop from ST using an ST virtual ‘request’ switch as a trigger, then:

  • Create your virtual switch in ST

On the PC/Laptop:

  • Create a command script to interrogate the switch status (this is to force a shut down):
    for /f "tokens=*" %%a in ('smartthings devices:component-status [ID]') do (
        if "%%a"==""value": "off"," (
            exit
 	    )
 	    if "%%a"==""value": "on"," (
 	    	shutdown -s -f -y -c "Shutdown at request of SmartThings"
	    )
     )
  • Create a task to run the command script at startup and to repeat (to poll switch state) at a suitable frequency - the default timing list can be overridden
  • Add a cli ‘off’ command for the ‘request’ switch in the shutdown script from previous posts to reflect in ST when it is picked up and actioned

Note:
For an ST created virtual switch the cli command above returns:

{
    "switch": {
        "switch": {
            "value": "off",
            "timestamp": "2026-01-24T14:24:58.905Z"
        }
    }
}