<% // Example of a very basic script to control the switching of appliances in a Plugwise network // from an IPhone. // Adjusted everything to work with the newest Source version 2.16, spierie-25012011 // to be precise: deleted the sorting of the TOP 10 appliances and made sure // the Undefined issues were deleted. Undefined is a new function in the 2.16 Source // it takes care of empty elements/arrays. // Michel Spierenburg-25012011 Format ".PowerUsage" As "{0:0}"; $clientName = "Plugwise"; %> <% echo Plugwise," - Mobile control" %> <% $pageSelection = Request.Get.containsKey("page")?Request.Get["page"]:""; echo '' // Switch anything? if (Request.Get.containsKey("cmd")) $cmd=Request.Get.containsKey("cmd")?Request.Get["cmd"]:"" // get the group id of the pressed button if Request.Get.containsKey("group") // get the appliances of that group $groupId = Request.Get.containsKey("group") ? Request.Get["group"]:0 $applianceIds = Plugwise.Groups[$groupId].Appliances.Keys elseif Request.Get.containsKey("app") $appId = Request.Get.containsKey("app") ? Request.Get["app"]:0 $applianceIds = { Plugwise.Appliances[$appId].Id } /if // Switch each of those appliances foreach $applianceIds with Appliance($_Value) if $cmd=="SwitchOn" .SwitchOn() elseif $cmd=="SwitchOff" .SwitchOff() /if /With /foreach // Reload page echo '' exit; /if // Deleted the sorting of TOP 10 appliances, spierie-25012011 // Define total power $grandtotal=0 foreach Plugwise.Appliances $grandtotal+=$_value.PowerUsage /foreach $pageTitlePower = "" + Math.Round($grandtotal) // make a string from power // Define page title if $pageSelection == "all" $pageTitle = $clientName+" apparaten - " +$pageTitlePower+" W" else $pageTitle = $clientName+" groepen - " +$pageTitlePower+" W" /if %>
<% echo $pageTitle %>
<% if $pageSelection == "all" echo '' echo '' echo '' echo '' echo '' echo '' foreach Plugwise.Appliances $appId = $_Value.ID; $name = $_Value.Name; $power = Math.Round($_Value.PowerUsage); echo '' echo '' echo '' echo '' echo '' echo '' echo '' /foreach else echo '' echo '' // echo '' echo '' echo '' echo '' // Create the buttons foreach Plugwise.Groups // only groups starting with '' should be displayed.' //if ($_Value.Name.Substring(0,9)=="") // Use the group name without Screen - as the button title $name=$_Value.Name.Substring(0).Trim() echo '' echo '' echo '' echo '' echo '' echo '' echo '' ///if /foreach /if %>
Terug naar de groepen
Terug
',$name,'
(',$power,' W)
UitAan
Apparaten selectie
Top10Terug
',$name,'
(',$_Value.PowerUsage,' W)
UitAan