A little HELP for security SCRIPTING

Forum with questions and discussions about security or security devices like Marmitek, Elro Elk (other then Visonic)
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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
User avatar
Noel
Senior Member
Senior Member
Posts: 1887
Joined: Tue Feb 12, 2008 12:13 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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>
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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 :) :)
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post by Digit »

Just curious: what are those <b>&</b> in &hs and &for for?
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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)
User avatar
TANE
Forum Moderator
Forum Moderator
Posts: 4806
Joined: Fri Apr 06, 2007 9:46 pm
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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?
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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 :-)
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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...
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post by drmacchi »

removed "as string" then from HS LOG :
Error Running script, init error: Prevista istruzione
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post by drmacchi »

I confirm that plugin is written in VB.NET 2.0
Digit
Global Moderator
Global Moderator
Posts: 3388
Joined: Sat Mar 25, 2006 10:23 am
Location: Netherlands
Contact:

A little HELP for security SCRIPTING

Post 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 :-)
drmacchi
Advanced Member
Advanced Member
Posts: 827
Joined: Wed Aug 08, 2007 5:48 pm
Location: Italy

A little HELP for security SCRIPTING

Post 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!
Post Reply

Return to “Security & Alarmpanels Forum”