diff options
author | Ebus-at-dockstar <ebus@dockstar> | 2013-03-25 11:42:52 +0100 |
---|---|---|
committer | Ebus-at-dockstar <ebus@dockstar> | 2013-03-25 11:43:05 +0100 |
commit | 6f20cda5c3071e03d2a56dc8236a530582cad2b7 (patch) | |
tree | 0aec854bc129ccf44bf35b70aac86b50bd24fa85 | |
parent | 862282ce99760832d3e9e5b4b1171b861105e004 (diff) | |
download | ebus-alt-6f20cda5c3071e03d2a56dc8236a530582cad2b7.tar.gz ebus-alt-6f20cda5c3071e03d2a56dc8236a530582cad2b7.zip |
neue datenquellen
-rwxr-xr-x | datasources/de_wettermichel.py | 46 | ||||
-rwxr-xr-x | datasources/yves_laserjet_tonerstatus.sh | 14 | ||||
-rw-r--r-- | ebus-datastore/ebus/web_static/src/ebus.js | 11 |
3 files changed, 70 insertions, 1 deletions
diff --git a/datasources/de_wettermichel.py b/datasources/de_wettermichel.py new file mode 100755 index 0000000..cf6a507 --- /dev/null +++ b/datasources/de_wettermichel.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# -*- coding:utf8 -*- +import httplib +from StringIO import StringIO +from lxml import objectify + +def read(): + conn = httplib.HTTPConnection("www.wettermichel.de") + conn.request("GET", "/weatherdata/params3.xml") + response = conn.getresponse() + assert response.status == 200, "Site status code == 200" + + xml = objectify.parse( response ) + conn.close() + return xml + +def insert(name, value, valueType): + conn = httplib.HTTPConnection("127.0.0.1:8000") + conn.request("PUT", + "/sensor/{n}".format(n=name), + "value={v}&type={t}".format(v=value, t=valueType)) + response = conn.getresponse() + assert response.status == 200, "put status code == 200" + conn.close() + + + + +for keyval in read().xpath("/data/*"): + if keyval.tag == "entry": + continue + + if isinstance(keyval, objectify.IntElement): + insert("de.wettermichel.{n}".format(n=keyval.tag), + keyval.text, "int") + elif isinstance(keyval, objectify.FloatElement): + insert("de.wettermichel.{n}".format(n=keyval.tag), + keyval.text, "float") + elif isinstance(keyval, objectify.StringElement): + # ignore strings + pass + else: + print "ignore other: %s %s" % (keyval.tag, keyval.__class__) + + +# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python diff --git a/datasources/yves_laserjet_tonerstatus.sh b/datasources/yves_laserjet_tonerstatus.sh new file mode 100755 index 0000000..6b7628a --- /dev/null +++ b/datasources/yves_laserjet_tonerstatus.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +name=yves.laserjet.tonerstatus +type=int + +curl -s "http://10.1.0.10/hp/device/info_suppliesStatus.html" | + sed -ne 's/.*>\([0-9]*\)%<.*/\1/p' | + ( + read value + curl -s -i -H "Accept: application/json" \ + -X PUT "http://localhost:8000/sensor/${name}" \ + -d "value=${value}&type=${type}" | + grep '"error": null' >/dev/null + ) diff --git a/ebus-datastore/ebus/web_static/src/ebus.js b/ebus-datastore/ebus/web_static/src/ebus.js index 1b8ef93..27802a9 100644 --- a/ebus-datastore/ebus/web_static/src/ebus.js +++ b/ebus-datastore/ebus/web_static/src/ebus.js @@ -1,3 +1,4 @@ +// vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=javascript var d = new Object(); d.ms = 1; d.sec = 1000*d.ms; @@ -59,7 +60,15 @@ $(document).ready(function(){ {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.kesselTemperatur", "description":"Kesseltemperatur", "show":false, - "color":"blue"} + "color":"blue"}, + {"sensorname":"de.wettermichel.temperature", + "description":"Aussentemperatur", + "show":true, + "color":"yellow"}, + {"sensorname":"yves.laserjet.tonerstatus", + "description":"Fuellstand Toner %", + "show":true, + "color":"black"} ]; var pickSensorConfig = function(sensorname) { |