[quote=“rostmo”]OK, I created a script which monitor the “status” of my BENQ projector. (Because the projector will turn on if I by error try to turn it off when its already off).
You should be able to use it for your purpose. The virtual switch (plugin) has ID 100 in my installation. You will need to find the unique ID in your setup and adjust the line “LOCAL dID = 100”. The rest should work if you use the same addon as in my setup.
This code will NOT try to turn off the BENQ if it’s not ON. IF the projector is ON it will turn off and set the virtual switch to off.
[font=courier]require “ircommand”
local dID = 100
local sID = “urn:upnp-org:serviceId:VSwitch1”
local TEMP= luup.variable_get(sID, “Status”, dID)
if (TEMP == “1”) then
ircommand.benqoff()
luup.call_action(sID, “SetTarget”, {newTargetValue = “0”}, dID)
end
ircommand.screenup()[/font]
This is another scene for turning everything on:
[font=courier]require “ircommand”
local dID = 100
local sID = “urn:upnp-org:serviceId:VSwitch1”
luup.call_action(sID, “SetTarget”, {newTargetValue = “1”}, dID)
ircommand.screendown()
ircommand.benqon()
ircommand.stream()[/font]
I use two scenes in my case above, but you can combine the two actions into one scene so you can use the same physical button trigger the same scene and send different ircommands based on status like this:
[font=courier]require “ircommand”
local dID = 100
local sID = “urn:upnp-org:serviceId:VSwitch1”
local TEMP= luup.variable_get(sID, “Status”, dID)
if (TEMP == “1”) then
ircommand.benqoff()
luup.call_action(sID, “SetTarget”, {newTargetValue = “0”}, dID)
else
ircommand.benqon()
luup.call_action(sID, “SetTarget”, {newTargetValue = “1”}, dID)
end[/font][/quote]
Simple but Elegant!
Works great!
Thanks a million Rostmo
I used the below code with virtual switch app (Id 133) and substituted my IR calls for Rostmo IR calls:
require “ircommand”
local dID = 100
local sID = “urn:upnp-org:serviceId:VSwitch1”
local TEMP= luup.variable_get(sID, “Status”, dID)
if (TEMP == “1”) then
ircommand.benqoff()
luup.call_action(sID, “SetTarget”, {newTargetValue = “0”}, dID)
else
ircommand.benqon()
luup.call_action(sID, “SetTarget”, {newTargetValue = “1”}, dID)
end