The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: xPLComfort install trouble




Hi Paul,

> > > I managed to get something like that working already. But
shouldn't I check that the
> > > incoming message is of the expected class (or schema I guess
is the right term in xPL
> > > land) for completeness?
> >
> > Yes - it wouldn't do any harm.
> Do you have any sample code? I know it should be simple, but I've only
been using the
> built in text editor, so it doesn't give any clues as to what methods
are available.

There is a section in the help file, under Scripting Reference, that
explains all the xPLHal-specific methods that have been added to VBScript.

To check the schema is sensor.basic, try something like:

If xpl.GetParam(XplMsg,"{SCHEMA}",True) =
"sensor.basic" Then
' Do stuff
Else
' Don't bother, because it's not a sensor.basic message.
End If

> >
> > > Next step is indeed conversion to names (along with phone
number to names). Got a
> mysql DB
> > > on a linux server...now will try and work out how to use
mysql from VB. I guess it's
> not
> > > hard.
> >
> > Just install the myODBC drivers for mySQL, and you should be able
to connect to it from
> VBScript just like any other database.
> >
> > I have a script in xPLHal that looks up a name from an SQL server
database - I'd be
> happy to share it if you feel it will be useful.
> Yes please. I installed the ODBC drivers and then got very confused
looking at the MS docs
> when looking for what to do next. I know this is simple, but I'm a
c/c++/java/perl/unix
> programmer and not vb/.net! For now I've got it working with a long
Select Case statement
> instead. Not ideal, but it does work :-)

OK. I have a function called MakePhoneNumber.
You pass it the actual phone number from the xPL message, and it looks it
up against a database and returns the person's name if found.
If no match is found, it just returns the phone number.

The Con.Open line is where you specify your ODBC connection string - I've
put in a mySQL connection string that I used to use a while ago when I used
mySQL, which should hopefully get you started.
Just substitute server name, UID, password and database as appropriate.
(and maybe the version number as well)

Function MakePhoneNumber(s)
dim Con, RS
dim Counter
dim PhoneNumber

Set Con = CreateObject("ADODB.Connection")
Set RS = CreateObject("ADODB.RecordSet")
Con.Open "DRIVER=MySQL ODBC 3.51
Driver;UID=homecontrol;PWD=********;SERVER=jupiter;DATABASE=telephones;OPTION=2"

RS.ActiveConnection = Con
RS.Open "SELECT * FROM People WHERE Telephone='" & s &
"' OR TelephoneMobile='" & s & "'"
If Not RS.Eof Then
PhoneNumber = RS("ContactFirstName") & " " &
RS("ContactName")
Else
PhoneNumber = ""
for Counter = 1 to len(s)
PhoneNumber = PhoneNumber & mid(s,Counter,1) & " "
Next
End If
RS.Close

MakePhoneNumber = PhoneNumber
Con.Close
Set RS = Nothing
Set Con = Nothing
End Function

Note that if the phone number isn't found, it is re-written with spaces
between each digit.
This is to prevent the TTS from announcing it as something like "two
hundred and twenty three thousand, six hundred and twenty seven",
which it does if it sees the number as one long string of digits.

HTH,

John



xPL Links: http://www.xplproject.org.uk http://www.xplhal.com http://www.xpl.myby.co.uk
To Post a Message: ukha_xpl@xxxxxxx
To Subscribe:  ukha_xpl-subscribe@xxxxxxx
To Unsubscribe:  ukha_xpl-unsubscribe@xxxxxxx

xPL Main Index | xPL Thread Index | xPL Home | Archives Home

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.