Page 1 of 3

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 8:28 pm
by drmacchi
Hi all, i need you SCRIPTS GURUS![:D]
I use Blade security plugin for homeseer; what i need is a script that:
sends an email using voipbuster , I HAVE IT:
<font color="red">&hs.launch "iexplore.exe", "https://myaccount.voipbuster.com/clx/se ... lmn"</font id="red">

PROBLEM is in TEXT , here i'd like to insert STATUS OF MOTION SENSORS USED by the plugin: about status i have a vb script:
<font color="red">&For Each d As String In hs.Plugin("BLSecurity").GetSecurityDevicesInAlert()
hs.writelog("Info", "Device: " & d & " is a device in alert!")
Next</font id="red">

how can i insert this status in TEXT? THANKS GUYS

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 9:27 pm
by Noel
Thats funny. I was also playing with this some days ago :-)
The way I'm trying this was by making use of PHP (yes I have PHP communicating with Homeseer).

Give me some days and I will publish the code here when done.

An other way to do this (I think) is by adding the URL in the "run script" within the action.
When in the "run script" mode select Advanced, and the above URL in the "OR Script Statement: ie: &hs.speak "hello"" box.
You will need to do this for ever sensor, and change the "text=" to the name of the sensor.

<h6>Anyone interested in time travel meet me here last Thursday!!

Download todays latest spoken weather (in Dutch) here (MP3).</h6>

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 10:40 pm
by drmacchi
Wifi, i'll wait for you! I have already inserted in "script statement" the URL for sms and it works (it was an old post may be yours)but i can not change TEXT with informations coming from vb status script. Go on guru :) :)

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 10:55 pm
by Digit
Just curious: what are those <b>&</b> in &hs and &for for?

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 11:24 pm
by drmacchi
FROM HELP of BLADE SECURITY PLUGIN:

HomeSeer Triggers and Actions
The BLSecurity Plug-In For HomeSeer provides many triggers and actions which can be used in your HomeSeer events.

BLSecurity Triggers

Security Mode Changed to ARMED
Security Mode Changed to PERIMETER
Security Mode Changed to SLEEP
Security Mode Changed to DISARMED
Alert Status Reset
Security Alert Triggered
Security Device in Alert When Arming
Security Device in Communication Error When Arming

BLSecurity Actions

Set Security Mode to ARMED
Set Security Mode to PERIMETER
Set Security Mode to SLEEP
Set Security Mode to DISARMED
Reset Alert Status
--------------------------------------------------------------------------------

Scripting Methods
Here is a list of the scripting methods that can be utilized with this plug-in.

Code: Select all

SetSecurityModeArmed Method
Parameter Type Description 
None 

Return Values Type Description 
None 

Description 
 This method sets the security mode to ARMED mode. 

VB.Net Scripting Example 

 hs.Plugin("BLSecurity").SetSecurityModeArmed() 

SetSecurityModePerimeter Method
Parameter Type Description 
None 

Return Values Type Description 
None 

Description 
 This method sets the security mode to PERIMETER mode. 

VB.Net Scripting Example 

 hs.Plugin("BLSecurity").SetSecurityModePerimeter() 

SetSecurityModeSleep Method
Parameter Type Description 
None 

Return Values Type Description 
None 

Description 
 This method sets the security mode to SLEEP mode. 

VB.Net Scripting Example 

 hs.Plugin("BLSecurity").SetSecurityModeSleep() 

SetSecurityModeDisarmed Method
Parameter Type Description 
None 

Return Values Type Description 
None 

Description 
 This method sets the security mode to DISARMED mode. 

VB.Net Scripting Example 

 hs.Plugin("BLSecurity").SetSecurityModeDisarmed() 

ResetAlertStatus Method
Parameter Type Description 
None 

Return Values Type Description 
None 

Description 
 This method resets the alert status to NORMAL. 

VB.Net Scripting Example 

 hs.Plugin("BLSecurity").ResetAlertStatus() 

GetSecurityDevicesInAlert Method
Parameter Type Description 
None 

Return Values Type Description 
Device Array Device String Array Returns a string array of devices. 

Description 
 This method returns a Device string array of devices in alert. 

VB.Net Scripting Example 

 For Each d As String In hs.Plugin("BLSecurity").GetSecurityDevicesInAlert() 
     hs.writelog("Info", "Device: " & d & " is a device in alert!") 
 Next 

GetSecurityDevicesInError Method
Parameter Type Description 
None 

Return Values Type Description 
Device Array Device String Array Returns a string array of devices. 

Description 
 This method returns a Device string array of devices in communication error. 

VB.Net Scripting Example 

 For Each d As String In hs.Plugin("BLSecurity").GetSecurityDevicesInError() 
     hs.writelog("Info", "Device: " & d & " is a device in communication error!") 
 Next

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 11:39 pm
by Digit
Still don't know what the &'s are for, so i'll pretend they're not there. Have you tried something like this:

Code: Select all

dim cDIA 
cDIA = ""
For Each d As String In hs.Plugin("BLSecurity").GetSecurityDevicesInAlert()
  if cDIA = "" then
    cDIA = d
  else  
    cDIA = cDIA & "," & d
  end if
Next

&hs.launch "iexplore.exe", "https://myaccount.voipbuster.com/clx/sendsms.php?username=xxxxxxxxx&password=xxxxxxxx&from=xxxxxxx&to=yyyyyyyyyy&text=" & cDIA
Another issue you'll have to solve is that when the text you want to send has spaces in them, you'll probably have to encode them (as in space becomes %20)

A little HELP for security SCRIPTING

Posted: Sun Nov 16, 2008 11:48 pm
by TANE
maybe this example will help.
I'm using this for Plugwise control

Sub Main(ByVal strAppCmd As String)
Dim strReturn, strWebsite As String
Dim strApp As String = hs.stringitem(strAppCmd, 1, ";")
Dim strCmd As String = hs.stringitem(strAppCmd, 2, ";")
strWebsite = "http://localhost:8080/cc.html?applid=" & strApp & "&cmd=" & strCmd
strReturn = hs.URLAction(strWebsite, "GET", "", "")
End Sub

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 12:53 am
by drmacchi
OH oh, too difficult for me, i'm not good to accomplish that! Digit, i tried pasting your suggestion in script field but it doesn't work (from HS LOG "Running script, init error: Previsto 'In'").
i was quite sure, may be i must refine the script , but i don't understan anything of scripting......sorry ! you don't know how much i'd like to be able to code all what you can do!
Is someone so gentle to write a code to simply paste in my homeseer?

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 1:15 am
by Digit
Ok; now i am wondering; both pieces of script you posted, you have actually seen them working?
If the answer is yes, i am lost since the error indicates i am trying to use a syntax that is not recognized.
(problem for me is that i am using to much different languages)
If the answer is no, there is still hope :-)

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 1:33 am
by drmacchi
Answer is NO (let's hope..)the only one that works is the part

&hs.launch "iexplore.exe", "https://myaccount.voipbuster.com/clx/se ... yyyy&text="........
Now i write MANUALLY a text and it works

the other portion is taken from plugin's guide above. i tried to copy it in HS , but it doesn't work. i think this part needs something to work

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 2:01 am
by Digit
Now i see, the 2nd piece with the foreach is vb.net code, not vbscript.
For each should work in vbscript. i think the "as string" is not recognized. Remove that part and try again, i can't test it here...

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 2:33 am
by drmacchi
removed "as string" then from HS LOG :
Error Running script, init error: Prevista istruzione

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 1:15 pm
by drmacchi
I confirm that plugin is written in VB.NET 2.0

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 1:32 pm
by Digit
I quickly read some things about HS scripting and understand a bit more now:
The "&" is used when you want to execute a one-liner.
If you need more then 1 line of code, you save the script in a file and add some extra code around it, like this:

Code: Select all

Sub Main()

  dim cDIA 
  cDIA = ""
  For Each d In hs.Plugin("BLSecurity").GetSecurityDevicesInAlert()
    if cDIA = "" then
      cDIA = d
    else  
      cDIA = cDIA & "," & d
    end if
  Next
  
  rs =  hs.urlaction("https://myaccount.voipbuster.com/clx/sendsms.php?username=xxxxxxxxx&password=xxxxxxxx&from=xxxxxxx&to=yyyyyyyyyy&text=" & cDIA, "GET", "", "")  

End Sub
(Maybe it was better to put this topic in HS forum :-)

A little HELP for security SCRIPTING

Posted: Mon Nov 17, 2008 1:49 pm
by drmacchi
Thanks Digit, i'll try it later. Domotica forum is better because i know that all you good guys like to help not expertise people like me! Sometimes threads in HS forum are not followed to the end, While this is a family where you can get always something good!