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: URL query and control?



------=_NextPart_000_0100_01CB6D23.8188CBE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Paul,

I wrote an app a while back called xAP DataParser, which may be able to
ach=
ieve this for you.

It's an app that you can send an url and a regular expression to via a xAP
=
message, and it will download the contents of the url (txt, html, xml,
etc)=
and then apply the regular expression, returning the result(s) as a xAP me=
ssage.

I drive this from Floorplan myself, to both send the initial command
messag=
e and then process the results, but would imagine that you can achieve the
=
same from HomeSeer (or even xAPFlash).

Take a look here http://www.ukha-archive.com/ml/xapdev/2009-jul/msg00006.ht=
ml


In your case, although the app is only interested in *downloading* the
cont=
ent at the end of the url, presumably the act of requesting that url from
y=
our heating controller would effectively carry out the desired control
acti=
on?  You'd need to write some regular expressions to pull the required
data=
from the returned XML, but that's fairly rudimentary with something like E=
xpresso.


Here's some examples of the Schema:

Query:

xap-header
{
v=3D12
Hop=3D1
UID=3DFF4FD900
Class=3Ddata.parser
Source=3DAHS.DataParser.AHSVMXAP
}
data.request
{
url=3Dhttp://www.national-lottery.co.uk/player/p/results/lotto.ftl
regularexpression=3Dmiddlecontent">(?:\s*)<ol>(?:\s*)<li>(\d+)</li>\s*<li>(=
\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</l=
i>\s*<li\sclass=3D"bonus">(\d+)</li>
resulttype=3Dsingle
target=3D*
queryname=3Ddefault
}

url - web page to parse
regularexpression - regular expression to parse the web page with
resulttype - whether you want a single xAP message in reply or multiple
xAP=
messages (there could be multiple matches to the regular expression)
target - reply messages can be either broadcast (*) or targetted
queryname - this will be reflected in the reply message (allows filtering
o=
f results by applications that sent the request)


Reply successful:

xap-header
{
v=3D12
Hop=3D1
UID=3DFF4FD900
Class=3Ddata.parser
Target=3Dmi4.floorplan.ahshaserver
Source=3DAHS.DataParser.AHSVMXAP
}
data.query
{
datetime=3D20090601143025
queryname=3Ddefault
success=3Dtrue
}
data.result.1
{
group1=3D02
group2=3D12
group3=3D24
group4=3D31
group5=3D41
group6=3D48
group7=3D40
}

obviously target in header will only be present if your query passed in a
t=
arget other than *.

data.query contains a datetime stamp and the queryname from your query
plus=
a "success" name/value pair which will be true or false

data.result.x contains the data parsed (it will always be .1 for
"multiple"=
resulttype queries or will be multiple blocks for "single"
resulttype quer=
ies)

group.x match the "matching groups" in your regular expression.


Reply unsuccessful:

xap-header
{
v=3D12
Hop=3D1
UID=3DFF4FD900
Class=3Ddata.parser
Source=3DAHS.DataParser.AHSVMXAP
}
data.query
{
url=3Dhttp://www.national-lottery.co.uk/player/p/results/lotto.ftl
regularexpression=3Dmiddlecontent">(?:\s*)<ol>(?:\s*)<li>(\d+)</li>\s*<li>(=
\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</li>\s*<li>(\d+)</l=
i>\s*<li\sclass=3D"bonus">(\d+) </li>
datetime=3D29/05/2009 16:19:41
resulttype=3Dsingle
target=3D*
queryname=3Ddefault
success=3Dfalse
}
data.result.1
{
group1=3Dno match found - possible regex error
}


Hope that's useful!


Martyn

----- Original Message -----=20
From: Paul Gale=20
To: xap_automation@xxxxxxx=20
Sent: Saturday, October 16, 2010 10:14 AM
Subject: RE: [xap_automation] URL query and control?





Thanks Patrick,

=20=20=20

Not sure if I explained myself very well?

=20=20=20

The heating manager runs on a small form factor PC and runs a web server =
and a wireless connection to the Honeywell heating system.

=20=20=20

To send heating commands, you can send data via the URL, for example:

=20=20=20

http://{webmanager}/api/control?action_name=3DturnOn&nodeId=3D57&username=
=3Dsystem&password=3Dsystem

=20=20=20

The unit returns:

=20=20=20

<control status=3D"ok"/>=20

(or a failed message)

=20=20=20

To query, you could send something like the following for a particular de=
vice:

http://{webmanager}/api/instances/50c5a00b16ce4c930116ce4c93a90007

which returns the XML:


<deviceInstance id=3D"50c5a00b16ce4c930116ce4c93a90007"
name=3D"Radiator He=
ating Controller (17409)"
deviceId=3D"org.annalytics.honeywell.drivers.Radi=
atorControllerDriver"><inputNodes/><outputNodes/><inputLevelNodes><node
nod=
eId=3D"117"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007"
onText=3D"On" o=
ffText=3D"Off" units=3D"Degrees"
scaleFactor=3D"1.0" minValue=3D"0.0" maxVa=
lue=3D"100.0" type=3D"2"
subtype=3D"TemperatureSensor" value=3D"15.91" valu=
eTimestamp=3D"0" enabled=3D"false"
status=3D"1" statusTimestamp=3D"0" nodeD=
riverService=3D"org.annalytics.honeywell.drivers.RadiatorControllerDriver"
=
index=3D"2"/><node nodeId=3D"118"
instanceId=3D"50c5a00b16ce4c930116ce4c93a=
90007" onText=3D"On" offText=3D"Off"
units=3D"%" scaleFactor=3D"1.0" minVal=
ue=3D"0.0" maxValue=3D"100.0" type=3D"2"
subtype=3D"BatteryLevel" value=3D"=
255.0" valueTimestamp=3D"0" enabled=3D"false"
status=3D"1" statusTimestamp=
=3D"0"
nodeDriverService=3D"org.annalytics.honeywell.drivers.RadiatorContro=
llerDriver" index=3D"3"/><node
nodeId=3D"119" instanceId=3D"50c5a00b16ce4c9=
30116ce4c93a90007" onText=3D"On" offText=3D"Off"
units=3D"%" scaleFactor=3D=
"1.0"minValue=3D"0.0" maxValue=3D"100.0"
type=3D"2" subtype=3D"Valve" value=
=3D"5.0" valueTimestamp=3D"0"
enabled=3D"false" status=3D"0"statusTimestamp=
=3D"0"
nodeDriverService=3D"org.annalytics.honeywell.drivers.RadiatorContro=
llerDriver"
index=3D"4"/></inputLevelNodes><outputLevelNodes><node
nodeId=
=3D"116"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007"
onText=3D"On" offT=
ext=3D"Off" units=3D"Degrees"
scaleFactor=3D"1.0" minValue=3D"0.0" maxValue=
=3D"100.0" type=3D"3"
subtype=3D"TemperatureController" value=3D"16.0" valu=
eTimestamp=3D"0" enabled=3D"false"
status=3D"0" statusTimestamp=3D"0" nodeD=
riverService=3D"org.annalytics.honeywell.drivers.RadiatorControllerDriver"
=
index=3D"1"/></outputLevelNodes></deviceInstance>=20

So I would need some XML parsing of the results and then be able to turn =
that into xAP BSC messages.

=20=20=20

Does that make sense? I wonder if this is best done in a HS script (as I'=
m no programmer)?

=20=20=20

Thanks,

=20=20=20

Paul.

=20=20=20

From: xap_automation@xxxxxxx [mailto:xap_automation@xxxxxxx=
om] On Behalf Of Patrick Lidstone
Sent: 15 October 2010 21:26
To: xap_automation@xxxxxxx
Subject: Re: [xap_automation] URL query and control?

=20=20=20



xAP-cache (http://patrick.lidstone.net/cache.htm)
can probably be bent to=
meet your needs, in that it can return a web page which contains user-defi=
ned fields based on the last n xAP messages of a particular
class/type/fiel=
d.

=20=20=20

To send xAP messages in response to hitting a URL, you can use any xAP co=
mmand line sender program on a web server, activated as a CGI script.

=20=20=20

To 'receive' xAP messages vial a URL or web service, you're going to need=
to periodically poll a cache of some kind.

=20=20=20

I really should get round to re-writing xAP-cache with a 'proper' web-ser=
vice interface. Ho hum.

=20=20=20

Patrick

=20=20=20

On 15 October 2010 17:50, Paul Gale <groups2@xxxxxxx> wrote:

Is there anything in the xap world or maybe in HomeSeer (and hence xapabl=
e) that would allow me to control a device that can be controlled and
queri=
ed via a URL and arguments?

The heating manager I have works in this way and I'd like to integrate it=
into xap flash.

Thanks,

Paul.

------------------------------------


xAP_Automation Main Index | xAP_Automation Thread Index | xAP_Automation 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.