Fork me on GitHub

pURL

Submitted by enrico.nicoletti on 2013, December 27 - 14:42
Your rating: None Average: 5 (2 votes)
Driver
Development Status: 
Prototype
Developer: 
enrico.nicoletti
Tested on: 
All supported
Download Link: 
Download Link: 
Short Description: 

Reads URLs content like XML, HTML, JSON and sends it in a listenable event. You can then bound a trigger to this event to create automations based on the URL content (eg: querying xml based web services)

THIS PLUGIN IS NOT COMPLETED, DO NOT USE IT IF NOT FOR TESTING PURPOSES. IT WILL WORK GREAT WITH THE UPCOMING XPATH FEATURE.

How it works

This plugin takes a set of urls (web services or standard web pages) from its manifest file, periodically gets their content (XML, JSON, HTML) and notifies it as a Freedomotic event. This event can be listened by the triggers shipped with this plugin (read temperature from URL, read weather from URL, ...) or you can create your own.

The triggers can be used as a data source for objects, like setting the temperature of a thermostat, or to create high level automations like

  • WHEN <your trigger here> THEN <say something using text to speech>
  • WHEN <your trigger here> THEN <send me an email>
  • WHEN <your trigger here> THEN <send a twitt>
  • WHEN <your trigger here> THEN <turn on a light>
  • let us know about your own triggers

 

Q: What about the plugin name?

A: The name is inspired by cURL command line linux program. http://en.wikipedia.org/wiki/CURL

Q: Where I can find example triggers?

A: As usual, they are in the data/trg folder in the plugin installation directory (freedomotic/plugins/devices/pURL/data/trg)

Q: How to reference the result of the XPATH query performed in the trigger?

A: The xpath query result is stored in property @event.url.content.xpathresult that you can use in commands. For example if you are parsing an XML content using an XPATH query to retrieve weather forecast, you can have a text to speech command like "say= Tomorrow will be @event.url.content.xpathresult" to hear "Tomorrow will be sunny"

How to configure

Actually you can just monitor a single URL changing it in the plugin manifest (menu Plugins -> Configure to edit). Detailed explanation coming when the plugin will be completed.

How to create custom triggers

Create a trigger (hardware level or not) which listen to messaging channel "app.event.sensor.url". This plugins notify the following properties in the event:

  • url: the source of data (eg: http://www.website.com/?q=aQuery)
  • url.content: the XML, JSON or HTML content of the web page
  • url.content.length: the number of characters readed from the url (always more than zero otherwise the event is not sent)

To know more about triggers read this wiki page.

Upcoming features

  • multi url monitoring
  • custom polling interval for each url
  • username/password authentication for protected urls
  • XPATH feature available in freedomotic-core to do xml queries directly in your trigger (Freedomotic v5.6)
Open Source Internet of Things Framework Drupal theme by Kiwi Themes.