The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Updated SendMyTxt SMS script for Homeseer


  • To: <ukha_d@xxxxxxx>
  • Subject: Updated SendMyTxt SMS script for Homeseer
  • From: "Alex Kinch" <alex@xxxxxxx>
  • Date: Thu, 3 Jul 2003 16:41:24 +0100
  • Mailing-list: list ukha_d@xxxxxxx; contact ukha_d-owner@xxxxxxx
  • References: <1057165133.4550.27173.m5@xxxxxxx>
  • Reply-to: ukha_d@xxxxxxx


Hello,

Here's an updated Homeseer script, which will allow you to send text
messages through the SendMyTxt http->sms gateway.

It now logs the amount of text credits remaining, and will alert you when
the threshhold (which you can set) is reached.

However.. the only thing I haven't done is written the bit of code to send
an email, as I've only been doing Homeseer scripting for the last day or
so.
Can someone kindly add it in?

Thanks,

Alex

'******************************************************************
'Script to send SMS messages using the sendmytxt.com service

'Call this function from your scripts or as a one-liner like this:
'hs.RunEx "sms.txt","SMS","RECIPIENT
NUMBER","TXTMESSAGE"
'e.g. hs.RunEx "sms.txt","sms","123456789,Hello
World"

Function sms(Params)

Dim MyMobileNum, PIN, Recipient, Message, host, page, Result, ResultCode,
ResultCredits, CreditThreshold, FromEmail, ToEmail

SMSinfo = Split(Params,",")

Recipient = Trim(SMSinfo(0))
Message = SMSInfo(1)

' #########################################################################
' # MAKE SURE YOU CHANGE THE FOLLOWING LINES BELOW!                       #
' #########################################################################

PIN = "1234" 'Your sendmytxt.com PIN goes here
MyMobileNum = "1234567890" 'The mobile number you registered goes
here
CreditThreshold = 5 ' Below this number, email is sent advising of low
credits
FromEmail = "me@myplace"
ToEmail = "you@wherever"


' #########################################################################
' # DO NOT CHANGE ANYTHING BELOW THIS LINE                                #
' #########################################################################

host = "sendmytxt.com"
page = "/app/httpsend.asp?"
page = page & "from=" & MyMobileNum &
"&to=" & Recipient & "&pin=" & PIN
page = page & "&message=" & Message
strip_tags = false 'true
port = 80


Result = Trim(hs.GetURL(host, page, strip_tags, port))
ResultCode = Left(Result,2)
ResultCredits = Right(Result,Len(Result)-3)

Select Case ResultCode

Case "0" ReturnVal = "No from number or pin entered"
Case "-1" Returnval = "from number not a registered
user"
Case "-2" ReturnVal = "incorrect pin"
Case "-3" ReturnVal = "account suspended"
Case "-4" ReturnVal = "insufficient credits"
Case "-5" ReturnVal = "message sending failed"
Case "-6" ReturnVal = "format of to number not
recognised"
Case "-7" ReturnVal = "format of from number not
recognised"
Case "ok" ReturnVal = "message sent successfully"

Case else ReturnVal = "Unknown response."

End Select

If ResultCredits < CreditThreshhold then

' send email here

End If

hs.writelog "SMS Info", "Sending message to: " &
Recipient
hs.writelog "SMS Info", "Message reads: " & Message
hs.writelog "SMS Info", "Service response: " &
ReturnVal
hs.writelog "SMS Info", "Credits remaining: " &
ResultCredits
sms = ReturnVal
End Function

'***********************************************************************



Home | Main Index | Thread Index

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.