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

October 21st, 2009, 07:13 PM
|
|
Seer
|
|
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
|
|
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.
|

October 21st, 2009, 08:13 PM
|
 |
OverSeer
|
|
Join Date: Jul 2001
Location: North Bend, WA, USA
Posts: 10,946
|
|
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")
|

October 21st, 2009, 08:59 PM
|
|
Seer Deluxe
|
|
Join Date: Mar 2006
Posts: 163
|
|
Quote:
Originally Posted by tailwind
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.
|

October 22nd, 2009, 04:44 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
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.
|

October 22nd, 2009, 08:20 AM
|
|
Seer
|
|
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
|
|
@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.
|

October 22nd, 2009, 08:47 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
To the best of my knowledge, it is not possible. You cannot convert a string directly to a homeseer script call.
__________________
Jon
|

October 22nd, 2009, 09:23 AM
|
|
Seer
|
|
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
|
|
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
|

October 22nd, 2009, 09:41 AM
|
 |
OverSeer
|
|
Join Date: Jan 2002
Location: London UK
Posts: 5,143
|
|
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
|

October 22nd, 2009, 02:11 PM
|
|
Seer Deluxe
|
|
Join Date: Apr 2001
Location: Columbus OH
Posts: 407
|
|
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
|

October 23rd, 2009, 10:10 AM
|
|
Seer
|
|
Join Date: Jul 2006
Location: The Netherlands
Posts: 9
|
|
Brilliant Jim! I just tested it and it works. Simple solution to what looked like a challenging problem
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
All times are GMT -4. The time now is 06:33 AM.
|