23rd August 2008 - There was an issue with our name caching server at around 08:00AM GMT. It has been fixed.

Getting variables out of Powerhome

HA... VIA Powerhome

Getting variables out of Powerhome

Postby martlist on Wed Mar 05, 2008 5:53 am

Dave just got my Insteon Thermostat working in powerhome and I am trying to work out how I would get the Current temperature, setpoint and mode out of powerhome. They are stored in a Virtual Control rather than Global Variables, but I cannot work out how to get either out so I can display in eHome.

I am guessing that using the socket server I can do anything.
martlist
 
Posts: 39
Joined: Sat Feb 09, 2008 8:17 am

Postby TonyNo on Wed Mar 05, 2008 12:15 pm

Are they virtual X10 devices?

If so, in the screen designer, create some labels, assign the element action as X10, then pick your devices.
TonyNo
 
Posts: 351
Joined: Sat Mar 17, 2007 3:53 pm
Location: Illinois USA

Postby TonyNo on Wed Mar 05, 2008 12:26 pm

Heh. I popped into the PH forum after here and saw that he was using virtual analog. Steve still needs to implement this, AFAIK.

Steve: Remember? ph_devicebtn? :D

Until Steve gets to it, you could use a bit of script to update the label caption when the screen changes...

This would be in your ehomeclient.vbs in ON_HA_SCRN_SWITCH()...

Code: Select all
dim resp

if sNewScreenName="your_screen" then

' TSTATTEMP
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 1 )"))
ehHaLabelChgCaption "screen_ID","label_ID", resp

end if
TonyNo
 
Posts: 351
Joined: Sat Mar 17, 2007 3:53 pm
Location: Illinois USA

Postby TonyNo on Wed Mar 05, 2008 12:47 pm

You could also use...

ph_insteonwithret( 'THERMOSTAT', 107, 3) / 2

instead of the ph_getotheranalog.
TonyNo
 
Posts: 351
Joined: Sat Mar 17, 2007 3:53 pm
Location: Illinois USA

Postby JakeBullet on Wed Mar 05, 2008 2:18 pm

Yep, I remember. :) Your getting pretty good with your VBS.
JakeBullet
Site Admin
 
Posts: 1102
Joined: Thu Mar 23, 2006 8:13 am

Postby martlist on Wed Mar 05, 2008 7:12 pm

Tony,

excellent. I guess it is time for me to make the jump from basic screen designing to VBS programming.

I am really a Java guy and have done very little scripting other than a little Perl in the past. Should be fun ;-)

I know what I am doing tonight.......

Martin
martlist
 
Posts: 39
Joined: Sat Feb 09, 2008 8:17 am

Postby martlist on Thu Mar 06, 2008 5:22 am

I guess I need to debug this more tomorrow as I think I have it setup right but the labels are not changing. I tried both calls to see if it made a difference and I have made sure the ids all match my screens and labels

Code: Select all
Function ON_HA_SCRN_SWITCH(sOldScreenName, sNewScreenName)
    '--- fires before a HA screen is shown - switched
    'msgbox "ON_HA_SCRN_SWITCH()"

dim resp

if sNewScreenName="hvac" then

' TSTATTEMP
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_insteonwithret( 'THERMOSTAT', 107, 3) / 2"))
ehHaLabelChgCaption "hvac","TSTATTEMP", resp

' TSTATSPB
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 3 )"))
ehHaLabelChgCaption "hvac","TSTATSPB", resp

' TSTATMODE
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 2 )"))
ehHaLabelChgCaption "hvac","TSTATMODE", resp

end if

End Function
martlist
 
Posts: 39
Joined: Sat Feb 09, 2008 8:17 am

Postby JakeBullet on Thu Mar 06, 2008 8:15 am

It looks good.

One thing though.

change
if sNewScreenName="hvac" then
to
if ucase(sNewScreenName) ="HVAC" then

Tony and I ran into a strange bug with this the other day. I have fixed it in the next version.


===========================================

A few pointers when writing script.

Don't use notepad. Use something like Notepad++
http://notepad-plus.sourceforge.net/uk/site.htm
It highlights everything and you can see obvious mistakes.

Also... You can use the DebugWindow window to watch messages. Its a small EXE --- DebugWindow.exe

So run DebugWindow.exe
Now your code could look like this

Code: Select all
Function ON_HA_SCRN_SWITCH(sOldScreenName, sNewScreenName)
    '--- fires before a HA screen is shown - switched
    'msgbox "ON_HA_SCRN_SWITCH()"

    g_oGbl.Send2DebugWindow "Start ON_HA_SCRN_SWITCH"

dim resp

if sNewScreenName="hvac" then


  g_oGbl.Send2DebugWindow "Hvac screen 1-  ON_HA_SCRN_SWITCH"
' TSTATTEMP
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_insteonwithret( 'THERMOSTAT', 107, 3) / 2"))
ehHaLabelChgCaption "hvac","TSTATTEMP", resp

  g_oGbl.Send2DebugWindow "Hvac screen 2-  ON_HA_SCRN_SWITCH"

' TSTATSPB
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 3 )"))
ehHaLabelChgCaption "hvac","TSTATSPB", resp


  g_oGbl.Send2DebugWindow "Hvac screen 3-  ON_HA_SCRN_SWITCH"

' TSTATMODE
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 2 )"))
ehHaLabelChgCaption "hvac","TSTATMODE", resp

end if

End Function


When you are done just REMARK out the Send2DebugWindow
So all of these
g_oGbl.Send2DebugWindow
become
'g_oGbl.Send2DebugWindow
JakeBullet
Site Admin
 
Posts: 1102
Joined: Thu Mar 23, 2006 8:13 am

Postby martlist on Fri Mar 07, 2008 4:30 am

There is a type mismatch in the ehCleanUpCRLF call. Will try and work out why. Could be something to do with the fact that the return is a string I think because it uses the message field to show Degrees in the Device Status. So it does not return 68 but 68 degrees. But I am shooting in the dark ;-)
martlist
 
Posts: 39
Joined: Sat Feb 09, 2008 8:17 am

Postby JakeBullet on Fri Mar 07, 2008 7:13 am

ehCleanUpCRLF is looking for a string. aaahhh a NULL will error it out.

Find your ehCleanUpCRLF function. It will be in the eHomeClientFunct.vbs file. replace it with this new function. Save and restart.


Code: Select all
'==================================================
Function ehCleanUpCRLF(sInVar)
    Dim sTemp
    sInVar = sInVar & "" '--- keep away the NULL's
    sTemp = Replace(sInVar, Chr(10), "")
    sTemp = Replace(sTemp, Chr(13), "")
    ehCleanUpCRLF = sTemp
End Function


OK - that will solve any NULL issues.

Now lets make it simple. Lets REMARK out all but one of your calls.
So lets get it to look something like this:

Code: Select all
dim resp
if sNewScreenName="hvac" then


g_oGbl.Send2DebugWindow "Hvac screen 1-  ON_HA_SCRN_SWITCH"
'--- TSTATTEMP
resp = ehCleanUpCRLF(g_oGbl.EH_PH_CALL_RETVAR("ph_insteonwithret( 'THERMOSTAT', 107, 3) / 2"))
ehHaLabelChgCaption "hvac","TSTATTEMP", resp

end if

REMARK out everything else.

replace with:
Code: Select all
dim resp
if sNewScreenName="hvac" then


g_oGbl.Send2DebugWindow "START -  ON_HA_SCRN_SWITCH"
'--- TSTATTEMP
resp = g_oGbl.EH_PH_CALL_RETVAR("ph_insteonwithret( 'THERMOSTAT', 107, 3) / 2")

g_oGbl.Send2DebugWindow "CALL -  ON_HA_SCRN_SWITCH- " & resp

resp = ehCleanUpCRLF(resp)

g_oGbl.Send2DebugWindow "CLEANUP -  ON_HA_SCRN_SWITCH- " & resp

ehHaLabelChgCaption "hvac","TSTATTEMP", resp

end if


Lets get this working 1st and then go onto the next.

Also. Have you verified that 'ph_insteonwithret' and the params you are using works in the PH socket server?

Also too - the next version has a few things to help you debug your VBS code.
JakeBullet
Site Admin
 
Posts: 1102
Joined: Thu Mar 23, 2006 8:13 am

Postby JakeBullet on Fri Mar 07, 2008 7:14 am

Tony

Does this look right to you? Its the '/ 2' that makes me think.

Code: Select all
g_oGbl.EH_PH_CALL_RETVAR("ph_insteonwithret( 'THERMOSTAT', 107,
3) / 2")
JakeBullet
Site Admin
 
Posts: 1102
Joined: Thu Mar 23, 2006 8:13 am

Postby TonyNo on Fri Mar 07, 2008 12:28 pm

That should work. I copied it from Dave's code. Apparently, the value returned is double what it should be. Maybe that would need to rely on eH to do the calc?

Try this...
Code: Select all
g_oGbl.EH_PH_CALL_RETVAR("ph_formula( ph_insteonwithret( 'THERMOSTAT', 107,
3) / 2"))


This would make it match the other two...
Code: Select all
g_oGbl.EH_PH_CALL_RETVAR("ph_getotheranalog( 'VIRT', 0, 1 )")
TonyNo
 
Posts: 351
Joined: Sat Mar 17, 2007 3:53 pm
Location: Illinois USA

Postby JakeBullet on Fri Mar 07, 2008 12:54 pm

That /2 is not going to work if '66 degrees' is coming back.
Need to try it without the /2 and see what is really coming back.
JakeBullet
Site Admin
 
Posts: 1102
Joined: Thu Mar 23, 2006 8:13 am

Postby TonyNo on Fri Mar 07, 2008 6:19 pm

I doubt that "66 degrees" is being returned. ph_getotheranalog and ph_insteonwithret only return numbers.
TonyNo
 
Posts: 351
Joined: Sat Mar 17, 2007 3:53 pm
Location: Illinois USA

Postby martlist on Fri Mar 07, 2008 6:34 pm

Well I found the problem. I didn't even have a ehCleanUpCRLF. i simply added it (couldn't replace what isn't ther) and voila it works. Didn't need to make any changes to the original code from Tony (added ucase as it was already there).

What I get back is 1, 69 and 70 as I would expect.

Dave uses a case statement in Powerhome to convert that first mode number into text. I am wondering if I should just put that into another field in powerhome and extract out that way or if I should do the same conversion on the eHome side. I guess either way works but it might be easier to do in powerhome and that way when powerhome changes later Ehome does not need to care.

Now this only triggers when I change screen. So it looks like I just need to make the HVAC screen not be the first HA screen and it should get updated every time. As the first screen I have to change off it and then change back.

Thanks for all the help and the tip about editor. Way simpler to see what is going on.
martlist
 
Posts: 39
Joined: Sat Feb 09, 2008 8:17 am

Next

Return to HA Stuff - Powerhome

Who is online

Users browsing this forum: No registered users and 1 guest



FREE FORUM Hosting by AtFreeForum. Create your Free WEB FORUM Hosting now!
GROUP DISCUSSION Features - Free FORUM HOSTING Directory Listing - DISCUSSION FORUM Terms of Service - FREE PHPBB Hosting Privacy
- FASHION ACCESSORIES