Variable refresh

Discussions about Mainlobby running on Apple mobile devices.
rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Variable refresh

Postby rileydog » Thu Sep 23, 2010 9:57 pm

I just finished my first scene for the iPhone - my Climate scene - I modified the one that was supplied.

It works perfect - except, I can't get the variables to refresh when I do actions - for example, the heat setpoint, cool setpoint, hold on, hold off, etc - the only one that resfreshes is the zone that I select.

If I leave the scene and go back, the variables are correct until I do more actions.

Is there something I need to do in HTML to get the variables to refresh?

Here is my HTML:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/styles.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<script src="javascript/iPhone.js" type="text/javascript"></script>
<title>Climate</title>
<script>
   function StartupMacro() {
      doCommand('MLConditional|IsNE##{{{{clientname}}_climate_init}}##1##Macro|' +
              'SetVariableFast|CurrentTempZone~1!' +
              'SetVariableFast|{{clientname}}_climate_init~1##');
      var zNum = "{{CurrentTempZone}}"
      if (zNum == "") {
         zNum = "1";
      }
      Zone(zNum);
      doCommand("IPHONE_HVAC_ZONECHANGE");
   }

   function Zone(zNum) {
      doCommand("Macro|SetVariableFast|CurrentTempZone~" + zNum + "!IPHONE_HVAC_ZONECHANGE");
      switch(zNum)
      {
         case '':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            break;
         case '1':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            break;
         case '2':
            document.getElementById('__Zone1').style.visibility='hidden';
            document.getElementById('__Zone2').style.visibility='visible';
            break;
      }
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
   }
   
   function Hold(zNum) {
      switch(zNum)
      {
         case '1':
            doCommand("MLHSPlugin|HS_RUNEX:haithermostat.txt~holdon~{"+"{CurrentTempZone}"+"}");
            break;
         case '2':
            doCommand("MLHSPlugin|HS_RUNEX:haithermostat.txt~holdoff~{"+"{CurrentTempZone}"+"}");
            break;
      }
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
   }

</script>
</head>

<body>
<div id="topbar" class="black">
   <div id="blueleftbutton"><a href="Index.html">Home</a></div>
   <div id="title">Climate</span></div>
</div>

<span id="__Zone1" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:107px; top:188px;font:normal 60px/65px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]51">{{mlhsplugin_]51}}</span>
   <span style="z-index:2; position:absolute; left:23px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]54">{{mlhsplugin_]54}}</span>
   <span style="z-index:2; position:absolute; left:260px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]55">{{mlhsplugin_]55}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:280px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]52">Mode: {{mlhsplugin_]52}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:137px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_V51">Hold: {{mlhsplugin_V51}}</span>
   <span style="z-index:2; position:absolute; left:85px; top:46px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__hvac_zonename_2">Zone: {{hvac_zonename_2}}</span>
</span>
<span id="__Zone2" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:107px; top:188px;font:normal 60px/65px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]56">{{mlhsplugin_]56}}</span>
   <span style="z-index:2; position:absolute; left:23px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]59">{{mlhsplugin_]59}}</span>
   <span style="z-index:2; position:absolute; left:260px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]60">{{mlhsplugin_]60}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:280px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]57">Mode: {{mlhsplugin_]57}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:137px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_V50">Hold: {{mlhsplugin_V50}}</span>
   <span style="z-index:2; position:absolute; left:100px; top:46px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__hvac_zonename_1">Zone: {{hvac_zonename_1}}</span>
</span>

<span style="z-index:2; position:absolute; left:27px; top:118px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
<span style="z-index:2; position:absolute; left:264px; top:118px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>
<span style="z-index:2; position:absolute; left:100px; top:330px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Thermostat Hold</span>

<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~CSPUp~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:12px; top:142px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~CSPDown~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:12px; top:245px;"><img src="images/ltblue/bDown1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~HSPUp~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:248px; top:142px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~HSPDown~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:248px; top:245px;"><img src="images/ltblue/bDown1.png" border="0"></span>

<div onclick="Zone('1');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:70px;left:170px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">South (Kitchen)</div>
<div onclick="Zone('2');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:70px;left:20px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">North (GR)</div>

<div onclick="Hold ('1');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:355px;left:20px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">On</div>
<div onclick="Hold ('2');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:355px;left:170px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">Off</div>

<span id="tabbar" style="visibility:visible;">
   <img src="images/tabbar.png" style="z-index:100;position:absolute;top:412px;left:0px;" />
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeoff~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:0px;" />
   <span style="z-index:102;position:absolute;top:424px;left:0px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Off</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeheat~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:80px;" />
   <span style="z-index:102;position:absolute;top:424px;left:80px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modecool~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:160px;" />
   <span style="z-index:102;position:absolute;top:424px;left:160px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeauto~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:240px;" />
   <span style="z-index:102;position:absolute;top:424px;left:240px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Auto</span>
</span>

<script language="javascript">
   autoupdate = true;
   pagevars = getvars();
   StartupMacro();
   UpdateVariables();
</script>
</body>
</html>

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 12:19 pm
Contact:

Re: Variable refresh

Postby bigDvette » Fri Sep 24, 2010 12:54 am

I haven't looked at the new libraries, but assuming they are close to the old ones aren't your IDs and your variables supposed to be the same?

Have you tried debugging it in safari on the PC. Open up the script debugger and see if your code is cycling through the updateVariables routine or not.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 9:48 am

Thanks for the ideas - the ID's are all the same except the preceding ml__ -- I think the iphone scripts need this to know to interact with ML (GetVar). I am not a java guy so this is all pretty new to me.

Here is what I observe:

The variables are correct when I load the page - any actions I do (change heat/cool setpoints, hold status, mode) work perfect - but, the variables are not refreshing - they are in ML.
When I leave the screen and go to the homepage then go back, it shows the correct variables until I do more actions
When I toggle between zones it shows the variables as they where when the page was loaded - so, any actions which do change the variables in ML are not refreshed until I reload the page.

Is there a way to have javascript refresh variables every few seconds or something?
You do not have the required permissions to view the files attached to this post.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 10:02 am

More info - in the ML Server log I do see frequent GETVAR commands issued from the browser and the variables are exactly what I expect.

So the script is getting the updated variables but they are not making it to thee page until I do a reload of the page. Any ideas? Thanks.

In the log:

Code: Select all

/GETVAR
/GETVAR - mlhsplugin_]51~mlhsplugin_]54~mlhsplugin_]55~mlhsplugin_]52~mlhsplugin_V51~hvac_zonename_2~mlhsplugin_]56~mlhsplugin_]59~mlhsplugin_]60~mlhsplugin_]57~mlhsplugin_V50~hvac_zonename_1

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 10:36 am

I got a workaround but it isn't slick - I added a javascript page refresh every 5 seconds - found this code and added it and it does work, but every 5 seconds I get a reload which can be annoying - still interested if anyone has suggestions on why the variables are not making it from the script refresh to the screen...

Code: Select all

   
 
<!-- Codes by Quackit.com -->
<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
   setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>
</head>
<body onload="JavaScript:timedRefresh(5000);">
<p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
<p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
</body>
</html>


User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Variable refresh

Postby CinemarDave » Fri Sep 24, 2010 3:46 pm

If you run this in desktop safari you'll see that the

Code: Select all

doCommand('MLConditional|IsNE##{{{{clientname}}_climate_init}}##1##Macro|' +
              'SetVariableFast|CurrentTempZone~1!' +
              'SetVariableFast|{{clientname}}_climate_init~1##');


function is throwing an error. At least for me and this is breaking the rest of ajax updating. I'm fixing it.

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Variable refresh

Postby CinemarDave » Fri Sep 24, 2010 7:08 pm

Version 4.0.1 of the iPhone web app fixes the JavaScript error on the climate.html page. It is now refreshing fine in simulation here for me.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 8:14 pm

I installed 4.01 and took out the screen refresh.

I am getting an xmlDocument error in the debug window every second - I enclosed the screen shot to show the error. There were 18 errors when I took the screen shot.

Here is my code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/styles.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<script src="javascript/iPhone.js" type="text/javascript"></script>
<title>Climate</title>
<script>
   function StartupMacro() {
      var zNum = "{{CurrentTempZone}}";
      if (zNum == "") {
         zNum = "1";
      }
      Zone(zNum);
   }

   function Zone(zNum) {
      doCommand("SetVariableFast|CurrentTempZone~" + zNum);
      switch(zNum)
      {
         case '':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            document.getElementById('__Zone3').style.visibility='hidden';
            break;
         case '1':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            document.getElementById('__Zone3').style.visibility='hidden';
            break;
         case '2':
            document.getElementById('__Zone1').style.visibility='hidden';
            document.getElementById('__Zone2').style.visibility='visible';
            document.getElementById('__Zone3').style.visibility='hidden';
            break;
         case '3':
            document.getElementById('__Zone1').style.visibility='hidden';
            document.getElementById('__Zone2').style.visibility='hidden';
            document.getElementById('__Zone3').style.visibility='visible';
            break;
      }
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
   }
</script>
</head>

<body>
<div id="topbar" class="black">
   <div id="blueleftbutton"><a href="Index.html">Home</a></div>
   <div id="title">Climate (Zone #<span id="ml__currenttempzone">{{currenttempzone}}</span>)</div>
</div>

<span id="__Zone1" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:110px; top:50px;font:normal 100px/110px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_1_Zone_Temp_Rnd">{{MLThermoStat_1_Zone_Temp_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:53px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_1_Cool_Point_Rnd">{{MLThermoStat_1_Cool_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:274px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_1_Heat_Point_Rnd">{{MLThermoStat_1_Heat_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:135px; top:170px;font:normal 32px/40px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_1_HVAC_Mode">{{MLThermoStat_1_HVAC_Mode}}</span>
</span>
<span id="__Zone2" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:110px; top:50px;font:normal 100px/110px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_2_Zone_Temp_Rnd">{{MLThermoStat_2_Zone_Temp_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:53px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_2_Cool_Point_Rnd">{{MLThermoStat_2_Cool_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:274px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_2_Heat_Point_Rnd">{{MLThermoStat_2_Heat_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:135px; top:170px;font:normal 32px/40px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_2_HVAC_Mode">{{MLThermoStat_2_HVAC_Mode}}</span>
</span>
<span id="__Zone3" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:110px; top:50px;font:normal 100px/110px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_3_Zone_Temp_Rnd">{{MLThermoStat_3_Zone_Temp_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:53px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_3_Cool_Point_Rnd">{{MLThermoStat_3_Cool_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:274px; top:162px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_3_Heat_Point_Rnd">{{MLThermoStat_3_Heat_Point_Rnd}}</span>
   <span style="z-index:2; position:absolute; left:135px; top:170px;font:normal 32px/40px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__MLThermoStat_3_HVAC_Mode">{{MLThermoStat_3_HVAC_Mode}}</span>
</span>

<span style="z-index:2; position:absolute; left:45px; top:145px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
<span style="z-index:2; position:absolute; left:265px; top:145px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>

<span onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~CoolPoint~Up');" style="z-index:3; position:absolute; left:32px; top:180px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~CoolPoint~Down');" style="z-index:3; position:absolute; left:32px; top:260px;"><img src="images/ltblue/bDown1.png" border="0"></span>
<span onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HeatPoint~Up');" style="z-index:3; position:absolute; left:248px; top:180px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HeatPoint~Down');" style="z-index:3; position:absolute; left:248px; top:260px;"><img src="images/ltblue/bDown1.png" border="0"></span>

<div onclick="Zone('1');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:360px;left:20px;width:80px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">Zone #1</div>
<div onclick="Zone('2');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:360px;left:120px;width:80px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">Zone #2</div>
<div onclick="Zone('3');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:360px;left:220px;width:80px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">Zone #3</div>

<span id="tabbar" style="visibility:visible;">
   <img src="images/tabbar.png" style="z-index:100;position:absolute;top:412px;left:0px;" />
   <img onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HVAC~Off');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:0px;" />
   <span style="z-index:102;position:absolute;top:424px;left:0px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Off</span>
   <img onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HVAC~Heat');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:80px;" />
   <span style="z-index:102;position:absolute;top:424px;left:80px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>
   <img onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HVAC~Cool');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:160px;" />
   <span style="z-index:102;position:absolute;top:424px;left:160px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
   <img onclick="doCommand('MLThermostat|{'+'{CurrentTempZone}'+'}~HVAC~Auto');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:240px;" />
   <span style="z-index:102;position:absolute;top:424px;left:240px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Auto</span>
</span>

<script language="javascript">
   autoupdate = true;
   pagevars = getvars();
   StartupMacro();
   UpdateVariables();
</script>
</body>
</html>


Thanks!
You do not have the required permissions to view the files attached to this post.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 8:16 pm

To be specific, 4.01 didn't fix the refresh issue - but, all the buttons work as I said in the original post - thanks,

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Variable refresh

Postby CinemarDave » Fri Sep 24, 2010 9:13 pm

Are you sure you attached your code? It looks like my sample.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 9:20 pm

Duh - wrong screen. Sorry. Here it is:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/styles.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<script src="javascript/iPhone.js" type="text/javascript"></script>
<title>Climate</title>
<script>
   function StartupMacro() {
      var zNum = "{{CurrentTempZone}}";
      if (zNum == "") {
         zNum = "1";
      }
      Zone(zNum);
   }

   function Zone(zNum) {
      doCommand("Macro|SetVariableFast|CurrentTempZone~" + zNum + "!IPHONE_HVAC_ZONECHANGE");
      switch(zNum)
      {
         case '':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            break;
         case '1':
            document.getElementById('__Zone1').style.visibility='visible';
            document.getElementById('__Zone2').style.visibility='hidden';
            break;
         case '2':
            document.getElementById('__Zone1').style.visibility='hidden';
            document.getElementById('__Zone2').style.visibility='visible';
            break;
      }
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
   }
   
   function Hold(zNum) {
      switch(zNum)
      {
         case '1':
            doCommand("MLHSPlugin|HS_RUNEX:haithermostat.txt~holdon~{"+"{CurrentTempZone}"+"}");
            break;
         case '2':
            doCommand("MLHSPlugin|HS_RUNEX:haithermostat.txt~holdoff~{"+"{CurrentTempZone}"+"}");
            break;
      }
   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
   }
   
   function timedRefresh(timeoutPeriod) {
      setTimeout("location.reload(true);",timeoutPeriod);
   }


</script>
</head>

<body>
<div id="topbar" class="black">
   <div id="blueleftbutton"><a href="Index.html">Home</a></div>
   <div id="title">Climate</div>
</div>

<span id="__Zone1" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:107px; top:188px;font:normal 60px/65px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]51">{{mlhsplugin_]51}}</span>
   <span style="z-index:2; position:absolute; left:23px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]54">{{mlhsplugin_]54}}</span>
   <span style="z-index:2; position:absolute; left:260px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]55">{{mlhsplugin_]55}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:280px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]52">Mode: {{mlhsplugin_]52}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:137px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_V51">Hold: {{mlhsplugin_V51}}</span>
   <span style="z-index:2; position:absolute; left:85px; top:46px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__hvac_zonename_2">Zone: {{hvac_zonename_2}}</span>
</span>
<span id="__Zone2" style="visibility:hidden;">
   <span style="z-index:2; position:absolute; left:107px; top:188px;font:normal 60px/65px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]56">{{mlhsplugin_]56}}</span>
   <span style="z-index:2; position:absolute; left:23px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]59">{{mlhsplugin_]59}}</span>
   <span style="z-index:2; position:absolute; left:260px; top:209px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]60">{{mlhsplugin_]60}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:280px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_]57">Mode: {{mlhsplugin_]57}}</span>
   <span style="z-index:2; position:absolute; left:90px; top:137px;font:normal 24px/32px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__mlhsplugin_V50">Hold: {{mlhsplugin_V50}}</span>
   <span style="z-index:2; position:absolute; left:100px; top:46px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);" id="ml__hvac_zonename_1">Zone: {{hvac_zonename_1}}</span>
</span>

<span style="z-index:2; position:absolute; left:27px; top:118px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
<span style="z-index:2; position:absolute; left:264px; top:118px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>
<span style="z-index:2; position:absolute; left:100px; top:330px;font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);">Thermostat Hold</span>

<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~CSPUp~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:12px; top:142px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~CSPDown~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:12px; top:245px;"><img src="images/ltblue/bDown1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~HSPUp~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:248px; top:142px;"><img src="images/ltblue/bUp1.png" border="0"></span>
<span onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~HSPDown~{'+'{CurrentTempZone}'+'}');" style="z-index:3; position:absolute; left:248px; top:245px;"><img src="images/ltblue/bDown1.png" border="0"></span>

<div onclick="Zone('1');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:70px;left:170px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">South (Kitchen)</div>
<div onclick="Zone('2');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:70px;left:20px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">North (GR)</div>

<div onclick="Hold ('1');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:355px;left:20px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">On</div>
<div onclick="Hold ('2');" style="font:normal 16px/20px Helvetica;color:rgba(255, 255, 255, 1.0);text-align:center;position:absolute;top:355px;left:170px;width:120px;line-height:30px;height:30px;-webkit-border-image:url('images/navbuttonblue.png') 0 5 0 5;border-width:0 5px;-webkit-border-radius:6px;">Off</div>

<span id="tabbar" style="visibility:visible;">
   <img src="images/tabbar.png" style="z-index:100;position:absolute;top:412px;left:0px;" />
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeoff~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:0px;" />
   <span style="z-index:102;position:absolute;top:424px;left:0px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Off</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeheat~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:80px;" />
   <span style="z-index:102;position:absolute;top:424px;left:80px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Heat</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modecool~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:160px;" />
   <span style="z-index:102;position:absolute;top:424px;left:160px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Cool</span>
   <img onclick="doCommand('MLHSPlugin|HS_RUNEX:haithermostat.txt~modeauto~{'+'{CurrentTempZone}'+'}');" src="images/tEmpty.png" style="z-index:101;position:absolute;top:410px;left:240px;" />
   <span style="z-index:102;position:absolute;top:424px;left:240px;width:80px;height:20px;padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;text-align:center;font:normal 20px/24px Helvetica;color:rgba(255, 255, 255, 1.0);">Auto</span>
</span>

<script language="javascript">
   autoupdate = true;
   pagevars = getvars();
   StartupMacro();
   UpdateVariables();
</script>
</body>
</html>

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 12:19 pm
Contact:

Re: Variable refresh

Postby bigDvette » Fri Sep 24, 2010 10:17 pm

I can tell you why it isn't working but not how to fix it.

Your variables with _] are messing up the XML return document. If you were to remove all the _] instances from your html, the return from Getvar does not result in a null responseXML.

If we were to look at responseText you are getting back

"<?xml version="1.0" standalone="yes"?><vars><mlhsplugin_]51></mlhsplugin_]51><mlhsplugin_]54></mlhsplugin_]54><mlhsplugin_]55></mlhsplugin_]55><mlhsplugin_]52></mlhsplugin_]52><mlhsplugin_V51></mlhsplugin_V51><hvac_zonename_2></hvac_zonename_2><mlhsplugin_]56></mlhsplugin_]56><mlhsplugin_]59></mlhsplugin_]59><mlhsplugin_]60></mlhsplugin_]60><mlhsplugin_]57></mlhsplugin_]57><mlhsplugin_V50></mlhsplugin_V50><hvac_zonename_1></hvac_zonename_1></vars>"

of course you would have variables in there. If you changed line 51 to xmlreq.responseText instead of responseXML, it will work. I'm not suggesting you do that, but somewhere between the MLServer and creation of the DOM document from the response, the data being returned is not being properly parsed in to XML.

bigDvette
Expert
Expert
Posts: 718
Joined: Thu Oct 12, 2006 12:19 pm
Contact:

Re: Variable refresh

Postby bigDvette » Fri Sep 24, 2010 10:20 pm

as a test you could create variables in MLServer that mask out that problem.

say create a variable callled

mlhsplugin_51 with a value of {{mlhsplugin_]51}}

and then change your variable to ml__mlhsplugin_51.

I think that work in ml server, but I don't mess with my vars that often.

Might be worth a try in case this isn't a quick fix.

rileydog
Expert
Expert
Posts: 667
Joined: Wed Jun 02, 2004 12:25 am
Location: Kalamazoo, Michigan
Contact:

Re: Variable refresh

Postby rileydog » Fri Sep 24, 2010 10:40 pm

Thanks - that makes sense to me.

I will switch the variables to more traditional names...

User avatar
Krumpy
Developer
Developer
Posts: 1228
Joined: Thu Sep 04, 2003 10:17 pm
Location: Minneapolis, Mn
Contact:

Re: Variable refresh

Postby Krumpy » Sat Sep 25, 2010 9:04 am

Or use the device name instead of the x10 code. Later versions of MOHs plugin support usage of device names also.

I myself have trasitiooned over and no longer use x10codes.


Return to “MainLobby on iPhone, iPod Touch”

Who is online

Users browsing this forum: No registered users and 1 guest