Problem with Command

Discussions about Mainlobby running on Apple mobile devices.
sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 9:02 am

I am trying to set up the new iPhone pages to use my lighting commands since I use Homeseer to control my lights. I set up a two rules in Mlserver like this:

Whenever mlhsplugin_q19 changes value
then MLServeCmd.SetVariable|mllighting_1_level~{{mlhsplugin_q19_value}}
and another one: (two separate rules)
Whenever mllighting_1_level changes value
then MLServeCmd.MLHSPlugin|HS.Execx10:q19:DDIM~{{mllighting_1_level}}

When I change the value in ML interface or HS, then the first one works, and the ipod changes, but if I try to change in from the ipod then the mllighting variable changes, but the light doesn't change.

Not sure what is happening. Can someone give me a push in the right direction?

Thanks.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 10:28 am

Because there are no standard lighting commands the lighting pages are only demos. They only set server variables and do not control any lights. If you want to make yours work you'll have to modify the HTML code. In your case try this experiment. Open the Lighting-Room1.html file in a text editor. WordPad will do. Notepad++ is really good. Look for the following routine in the <Script> section.

Code: Select all

$('slider1handle').addEventListener('touchend', function(event) {
   var sVal = Math.floor(Sliders[0].curX / Sliders[0].maxX * 100);
   $('ml__mllighting_1_level').innerHTML = "Pos:" + Sliders[0].curX + " Val:" + sVal;
   doCommand("SetVariableFast|mllighting_1_level~"+sVal);
}, false);


Change this routine to read. Notice the new doCommand,

Code: Select all

$('slider1handle').addEventListener('touchend', function(event) {
   var sVal = Math.floor(Sliders[0].curX / Sliders[0].maxX * 100);
   $('ml__mllighting_1_level').innerHTML = "Pos:" + Sliders[0].curX + " Val:" + sVal;
   doCommand("MLHSPlugin|HS.Execx10:q19:DDIM~"+sVal);
}, false);


Then in the HTML section look for the commands for the on and off buttons. They'll look like this

Code: Select all

<span onclick="doCommand('SetVariableFast|mllighting_1_level~0');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:45px;">&nbsp;&nbsp;Off&nbsp;&nbsp;</span>
<span onclick="doCommand('SetVariableFast|mllighting_1_level~100');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:220px;">&nbsp;&nbsp;On&nbsp;&nbsp;</span>


Change the doCommands to the appropriate HomeSeer command. Some like this I guess

Code: Select all

<span onclick="doCommand('MLHSPlugin|HS.Execx10:q19:DDIM~0');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:45px;">&nbsp;&nbsp;Off&nbsp;&nbsp;</span>
<span onclick="doCommand('MLHSPlugin|HS.Execx10:q19:DDIM~~100');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:220px;">&nbsp;&nbsp;On&nbsp;&nbsp;</span>


This should now make your light turn on, off and dim. Once you have this working you'll have to make similar changes to control your other lights. Also, you do not have to use the "lighting_x_level" server variables. If you have Homeseer server variables that track the level use them and eliminate the need for the automation rule. Just look for each instance of lighting_1_level in the html and substitute the real server variable.

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 11:46 am

Dave,
Thank you as always. I got mot of it working Ok but I am having problems getting the second slider on the page to adjust to the value. I have the first slider set up like this:

<span id="ml__mlhsplugin_q19_value" _MLSlider="1" _MLSliderIndex="1" style="visibility:hidden;">{{mlhsplugin_q19_value}}</span>

and the second one like this:

<span id="ml__mlhsplugin_q44_value" _MLSlider="2" _MLSliderIndex="2" style="visibility:hidden;">{{mlhsplugin_q44_value}}</span>

The first one works good, but the second one doesn't. I now it has to be something simple but I can't figure it out.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 11:51 am

Did you also change the JavaScript for the second slider? Each slider has its own event listener

Code: Select all

$('slider2handle').addEventListener('touchend', function(event) {
   var sVal = Math.floor(Sliders[0].curX / Sliders[0].maxX * 100);
   $('ml__mlhsplugin_q44_value').innerHTML = sVal;
   doCommand("MLHSPlugin|HS.Execx10:q44:DDIM~"+sVal);
}, false);

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 1:46 pm

Yes I did. It didn't make a difference.

Thank you.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 1:48 pm

do you see the commands hitting MLServer? Events?

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 2:17 pm

I got it to work by setting up these lines like this:

<span id="ml__mlhsplugin_q19_value" _MLSlider="1" _MLSliderIndex="1" style="visibility:hidden;">{{mlhsplugin_q19_value}}</span>
and
<span id="ml__mlhsplugin_q44_value" _MLSlider="1" _MLSliderIndex="2" style="visibility:hidden;">{{mlhsplugin_q44_value}}</span>

Don't know if this is correct or not, but so far it seems to be working.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 2:19 pm

you got it.

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 6:06 pm

Thanks for your help Dave. And for a great interface. So far I really like the layout of everything. Can't wait to see the iPad version.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 6:11 pm

Glad to hear it is working out. I've tried to make it as turnkey as possible.

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Tue Sep 21, 2010 7:35 pm

And I think you have. I am just a little challenged when it comes to the commands. But usually when I get a push in the right direction I am OK.

On another front, it doesn't appear that the Climate screens are auto updating. If I click on the Zone buttons, the data changes, but the zone # at the top doesn't change. Also, if I make a change at the t-stat the screen doesn't show the update. If I go back to the main screen then back to the climate screen then everything updates.

Thanks.

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

Re: Problem with Command

Postby CinemarDave » Tue Sep 21, 2010 8:16 pm

Open the Climate.html file and find the StartupMacro routine. Change it so that it says this.

Code: Select all

   function StartupMacro() {
      var zNum = "{{CurrentTempZone}}";
      if (zNum == "") {
         zNum = "1";
      }
      Zone(zNum);
   }


Does this fix it?

sonypoolplr
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1490
Joined: Fri Mar 26, 2004 8:48 am
Location: New Jersey
Contact:

Re: Problem with Command

Postby sonypoolplr » Wed Sep 22, 2010 6:18 am

No Dave it didn't. The zones change, but they still bring up the old data, and the zone at the top doesn't change. The zone # variable is changing in ML, because I set up the variable on my Mainlobby scene and it changes.

Thanks.

shakey
Intermediate
Intermediate
Posts: 285
Joined: Sat Jun 28, 2008 9:55 pm
Contact:

Re: Problem with Command

Postby shakey » Mon Oct 11, 2010 10:01 pm

I'm having trouble getting sliders to work properly. My command buttons work and will move the slider to on or off value but if Ithe drag slider the light does not change and goes back to the full off or on position depending on the light status.

Here is the code what do i have wrong?

Thanks,
Shakey

$('slider1handle').addEventListener('touchend', function(event) {
var sVal = Math.floor(Sliders[0].curX / Sliders[0].maxX * 100);
$('ml_MLLighting_002_value').innerHTML = sVal;
doCommand("MLServeCmd.MLLighting|On~002~"+sVal);
}, false);

<span style="z-index:3;position:absolute;top:50px;left:20px;width:285px;height:34px;text-align:center;font:normal 22px/34px Helvetica;color:rgba(255, 255, 255, 1.0);padding:0px;border:0px;margin:0px;overflow:hidden;text-overflow:clip;">Island Lights</span>
<div class="sliderbase" style="z-index:2;position:absolute;top:80px;left:15px;">
<img id="slider1" src="images/Slider1.png" style="z-index:3;position:inherit;top:16px;left:58px;-webkit-transform:scale(1.45);" />
<img id="slider1handle" src="images/SliderHandle1.png" style="z-index:4;position:inherit;top:16px;left:7px;-webkit-transition: -webkit-transform 0.25s ease" />
<span id="ml__MLLighting_002_Value" _MLSlider="1" _MLSliderIndex="1" style="visibility:hidden;">{{mllighting_002_value}}</span>
</div>
<span onclick="doCommand('MLLighting|On~002~0');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:45px;">&nbsp;&nbsp;Off&nbsp;&nbsp;</span>
<span onclick="doCommand('MLLighting|On~002~100');" class="basebutton" style="z-index:2;position:absolute;top:165px;left:220px;">&nbsp;&nbsp;On&nbsp;&nbsp;</span>

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: Problem with Command

Postby ricks » Mon Oct 11, 2010 10:17 pm

Not that this may help much but as I struggled to get my variables to update I noticed something that helped me.

If I load the page on my iphone and then look at the MLServer log and DON'T see getvar, getvar, getvar... then I usually have a problem with the script at the bottom of the page which updates the variables. Check a page that does update and make sure the script commands are the same.

If I do get getvar, getvar, getvar and some but not all variables are updating, I usually find that I have made an error in the id portion of the variable line either by 1) forgetting to add the "ml__" or by 2) including {{ }} that shouldn't be there in the id.

If all else fails I find a variable on the page that does update and copy/paste the entire line of code over the variable that doesn't update and then change only the variable names to fit the variable I want. Once updating, I can then set the location, font, style, etc. as I want it.

Hope this helps anyone else who edits their pages.

Rick


Return to “MainLobby on iPhone, iPod Touch”

Who is online

Users browsing this forum: No registered users and 1 guest