HTTP Sensors

From eedomus - Documentation

Jump to: navigation, search

The box eedomus allows you to create virtual sensors using data contained in XML pages (and by extension some HTML pages). The data will be retrieved from an XML page with your box eedomus on a regular basis, and available in the web interface.

How?

Start by adding a module"HTTP - Sensor" with the interface eedomus (Setup / Add device / Other device types / HTTP - Sensor).

Then go to the screen Device Configuration to set your sensor:


An example of a sensor built around a test page made available on the server eedomus: http://api.eedomus.com/test/http_sensor_sample.xml.php

File: http_sensor_config.png

The semantics of expressions [XPath http://fr.wikipedia.org/wiki/XPath] is described [here http://fr.wikipedia.org/wiki/XPath].

Your expressions can be evaluated this test page


Note 1: This virtual sensor can collect integers, decimals (or text, limited to 40 characters).

Note 2: It is possible to determine a mapping between XML values ​​and the values ​​displayed in eedomus using the tab "Values" of your HTTP sensor.

Note 3: It is possible to hide the unity displayed by entering a space for this parameter is mandatory.

Note 4: Some XML encodings, such as iso-8859-15 may be a problem, do not hesitate to report cases that would not work.

Example

To retrieve information from an analog sensor of IPX800, the configuration is as follows

Request URL:  http://ici_adresse_IP_de_l IPX / status.xml 
XPath://year1 to retrieve the first analog input

Use Advanced with XPath Operators [1]

It is possible to manipulate the results of XML nodes with operators xPath, here are some examples:

  • To divide by 10 the result:
(/ SENSORS / TEMPERATURE / VALUE)div 10
  • To multiply the result by 100:
(/ SENSORS / TEMPERATURE / VALUE)* 100


The following functions are also supported:


To round fractions down (truncate)

floor (number)

To round to the next whole

ceiling (number)

For rounding to the nearest entry

round (number)

To count the number of nodes that will return the XPath

count (xpath)

To concatenate two strings

concat (string1, string2)

Get just one part of a string

substring (string, start, length)
substring (string, start)

Leaving only the data before a given character

substring-before (string1, string2)

Leaving only the data after a given character

substring-after (string1, string2)

To retrieve the length of a string

string-length (string)


To replace characters with other

translate (string1, string2, string3)

Example: translate ('12: 30','30','45 ') Result:'12:45'

Example: translate ('12:30','03','54') Result:'12:45'

Example:translate ('12:30','0123','abcd') Result:'bc:da'


Function replace () is not supported, but a specific function change () can be used. The function can be pellée one or more times in late XPath expression to replace one string in another:

exchange (string, search new_string)


Some examples of using functions:

  • To keep that data after the '.':
substring-after (/ SENSORS / TEMPERATURE / VALUE,'.')
  • To retrieve only the 2nd character read:
substring (/ SENSORS / TEMPERATURE / VALUE,2,1)
  • To count the number of XML nodes:
count (/ SENSORS / TEMPERATURE)