Windows PC remote control (Shutdown, ...)

To make this thread complete, here’s a short example, only checking the online state and sending two commands. It’s easily extended.

pc.items:

Switch WZ_PC_Online "PC WinThing Online" { mqtt="<[broker:winthing/system/system/online:state:MAP(truefalse.map)]" }
String WZ_PC_Command "PC Command"

sitemap:

Switch item=WZ_PC_Online
Switch item=WZ_PC_Command mappings=[shutdown="Shutdown", kodi="Start Kodi"]

pc.rules:

rule "PC Command"
when
	Item WZ_PC_Command received command
then 
	switch (receivedCommand) {
		case "shutdown" : {
			publish("broker", "winthing/system/commands/shutdown", "now") 
  		}
		case "kodi" : {
			publish("broker", "winthing/system/commands/run", '["C:/Program Files (x86)/Kodi/Kodi.exe"]')
		}
	}
	WZ_PC_Command.postUpdate(NULL)
end
4 Likes