www.homeseer.com

Go Back   HomeSeer Message Board > Developer Support > Programming with HomeSeer

Programming with HomeSeer Discussions related to custom programming using the HomeSeer ActiveX interface. This includes Visual Basic, ASP, and C++.

Reply
 
Thread Tools Display Modes
  #1  
Old October 21st, 2009, 07:13 PM
tailwind tailwind is offline
Seer
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
Question hs.sunset as parameter to script

I've created a script which makes it possible to display a text on a Squeezebox.

The script parameters are -->
SBMessage.vb("Main","IPADDRESS;MESSAGELINE1;MESSAGELINE2;DURATION;BRIGHTNESS")

What I want to do is display the sunset time on the squeezebox. The command I've tried is:
SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om " &hs.Sunset & ";5;4")

That results in the string being cut off at "Zonsondergang vandaag om ".

I also tried:
SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om &hs.Sunset ;5;4")

and

SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om hs.Sunset ;5;4")

Is it possible to pass of a homeseer command to the parameters? And if so...how?

p.s. If you want I can attach the script, but you will need a Squeezebox server (or Squeezecenter server) with a device which has a display (Squeezebox/Transporter) to test it.
Reply With Quote
  #2  
Old October 21st, 2009, 08:13 PM
Michael McSharry's Avatar
Michael McSharry Michael McSharry is offline
OverSeer
 
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 10,946
Default

I'm not a .vb scripter, but one suggestion is that you may need typecasting on hs.sunset() such as

SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om " & cstr(hs.Sunset()) & ";5;4")
Reply With Quote
  #3  
Old October 21st, 2009, 08:59 PM
IKUS IKUS is offline
Seer Deluxe
 
Join Date: Mar 2006
Posts: 163
Default

Quote:
Originally Posted by tailwind View Post
Is it possible to pass of a homeseer command to the parameters? And if so...how?
I don't think you can pass an "immediate homeseer command" as a parameter. I'm hoping I'm wrong though 'cause I too have tried to do this (albeit with a JavaScriipt script) with no success but would love to be able to.
Reply With Quote
  #4  
Old October 22nd, 2009, 04:44 AM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 5,143
Default

As stated, you cannot do this.

The workaround is to use keywords which are then replaced within the main script.

Example, using keyword $SS for sunset:

Script call:

SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om $SS";5;4")

Within main script:

If Instr(sMLine2,"$SS") > 0 then sMLine2=hs.stringitem(sMLine2,1,"$SS") & hs.sunset() & hs.stringitem(sMLine2,2,"$SS")

(You can use the split command instead if you wish).
__________________
Jon


Last edited by jon00; October 22nd, 2009 at 05:16 AM.
Reply With Quote
  #5  
Old October 22nd, 2009, 08:20 AM
tailwind tailwind is offline
Seer
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
Lightbulb

@jon00: The problem with your solution is that you never know what someone is requesting. It's not always sunset. It can also be a device command or something else.

So the question is: Is there a function available containing all homeseer commands? That way you can do something like this:

Script call:
SBMessage.vb("Main","localhost;Zonnetijden;Zonsondergang vandaag om $SS";5;4")

In SBMessage.vb:
- Split the parameters on VbSpace
- Loop through the array of splitted parameters and do an instring $
- If $ is found then call function with the $.... command
- The function picks up the $... command, executes it and returns the value.
- Back in the loop the value is replaced with the homeseer value
- after the loop is done, the string is rebuild with the replaced stuff

This way it's totally dynamic.

As I see it, the above would be a workaround. The best way (in my oppinion) is to let HomeSeer support the hs commands from the parameters field in a later version. I can immagin that there are more people who want this functionality.
Reply With Quote
  #6  
Old October 22nd, 2009, 08:47 AM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 5,143
Default

To the best of my knowledge, it is not possible. You cannot convert a string directly to a homeseer script call.
__________________
Jon

Reply With Quote
  #7  
Old October 22nd, 2009, 09:23 AM
tailwind tailwind is offline
Seer
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
Default

Sorry jon I wan't clear enough. The function does not launch the string it recieves it just recognise the command to be executed based on an $.... string and executes the corresponding homeseer command. Something like this:

StringInput = "$ss"

function:
Select
Case LCase(StringInput) = "$ss"
Return hs.Sunset
Case LCase(StringInput) = "$sr"
Return hs.Sunrise
Case ...
EndSelect
Reply With Quote
  #8  
Old October 22nd, 2009, 09:41 AM
jon00's Avatar
jon00 jon00 is offline
OverSeer
 
Join Date: Jan 2002
Location: London UK
Posts: 5,143
Default

The return would be a string, but again you would need to replace the string input command and insert it within the original message.
__________________
Jon

Reply With Quote
  #9  
Old October 22nd, 2009, 02:11 PM
jsteed jsteed is offline
Seer Deluxe
 
Join Date: Apr 2001
Location: Columbus OH
Posts: 407
Default

I think what you want is to use the "OR Script Statement:" entry and use hs.RunEx to run the script instead of directly entering the script name and parameters.

&hs.RunEx("test.txt","Main","Today at "&hs.sunset&" evening")

10/22/2009 1:01:34 PM ~!~Event~!~Running script statement immediately: &hs.RunEx("test.txt","Main","Today at "&hs.sunset&" evening")
10/22/2009 1:01:34 PM ~!~test~!~Today at 6:42 PM evening

jim
Reply With Quote
  #10  
Old October 23rd, 2009, 10:10 AM
tailwind tailwind is offline
Seer
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
Thumbs up

Brilliant Jim! I just tested it and it works. Simple solution to what looked like a challenging problem
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:33 AM.


Copyright 1998-2008 HomeSeer Technologies, LLC