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?



--_000_3079CB5C2E04AC4CBE86C8C0093B2BB7011210C1EXCHANGEhomesil_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hey Martin- thanks for that, it looks excellent. I'll explore it further
an=
d see how I get on :)

Many thanks,

Paul.

From: xap_automation@xxxxxxx [mailto:xap_automation@xxxxxxx=
] On Behalf Of Martyn Wendon
Sent: 16 October 2010 11:16
To: xap_automation@xxxxxxx
Subject: Re: [xap_automation] URL query and control?




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 -----
From: Paul Gale<mailto:groups2@xxxxxxx>
To: xap_automation@xxxxxxx<mailto:xap_automation@xxxxxxx>
Sent: Saturday, October 16, 2010 10:14 AM
Subject: RE: [xap_automation] URL query and control?

Thanks Patrick,

Not sure if I explained myself very well?

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

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

http://{webmanager}/api/control?action_name=3DturnOn&nodeId=3D57&username=
=3Dsystem&password=3Dsystem<http://%7bwebmanager%7d/api/control?action_name=
=3DturnOn&nodeId=3D57&username=3Dsystem&password=3Dsystem>

The unit returns:


<control status=3D"ok"/>

(or a failed message)

To query, you could send something like the following for a particular
devi=
ce:
http://{webmanager}/api/instances/50c5a00b16ce4c930116ce4c93a90007<http://%=
7bwebmanager%7d/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 nodeId=3D"117"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007" onText=
=3D"On" offText=3D"Off" units=3D"Degrees"
scaleFactor=3D"1.0"

minValue=3D"0.0" maxValue=3D"100.0"
type=3D"2" subtype=3D"TemperatureSenso=
r" value=3D"15.91" valueTimestamp=3D"0"
enabled=3D"false" status=3D"1"

statusTimestamp=3D"0"
nodeDriverService=3D"org.annalytics.honeywell.driver=
s.RadiatorControllerDriver" index=3D"2"/>

<node nodeId=3D"118"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007" 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"BatteryLevel" va=
lue=3D"255.0" valueTimestamp=3D"0"
enabled=3D"false" status=3D"1"

statusTimestamp=3D"0"
nodeDriverService=3D"org.annalytics.honeywell.driver=
s.RadiatorControllerDriver" index=3D"3"/>

<node nodeId=3D"119"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007" 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=
.RadiatorControllerDriver" index=3D"4"/>

</inputLevelNodes>

<outputLevelNodes>

<node nodeId=3D"116"
instanceId=3D"50c5a00b16ce4c930116ce4c93a90007" onText=
=3D"On" offText=3D"Off" units=3D"Degrees"
scaleFactor=3D"1.0"

minValue=3D"0.0" maxValue=3D"100.0"
type=3D"3" subtype=3D"TemperatureContr=
oller" value=3D"16.0" valueTimestamp=3D"0"
enabled=3D"false" status=3D"0"

statusTimestamp=3D"0"
nodeDriverService=3D"org.annalytics.honeywell.driver=
s.RadiatorControllerDriver" index=3D"1"/>

</outputLevelNodes>

</deviceInstance>

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

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

Thanks,

Paul.

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



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

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

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

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

Patrick

On 15 October 2010 17:50, Paul Gale <groups2@xxxxxxx<mailto:groups=
2@xxxxxxx>> wrote:
Is there anything in the xap world or maybe in HomeSeer (and hence
xapable)=
that would allow me to control a device that can be controlled and queried=
via a URL and arguments?

The heating manager I have works in this way and I'd like to integrate it
i=
nto 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.