Bwired Googlemaps upload data webservice

Forum about Questions, discussions and announcements regarding the Bwired website owned by Pieter Knuvers

Bwired Googlemaps upload data webservice

Postby Bwired » Fri Mar 13, 2009 7:20 pm

Hi all,
As promised the Bwired XML upload data service is ready check the result at:
http://www.bwired.nl/domoticaworld.asp
It is now possible to upload your domotica Home Automation sensor data to the Bwired webserver. So Come on! :-)
The data is handled automatic and stored in a database (I tell you this upfront [:D]).
The data is stored per day so high and low values can be generated.
It would be nice the have outside Temp, Humidity, Energy, Water and Gas as standard devices.

If you want to upload some sensordata proceed as follows:

Make it possible that you can create an XML file with the following format:
<b>(Don't Leave any elements out, if not used leave the value blank)</b>

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<BWired>
<Init>
   <DateTime>13-3-2009 19:01:00</DateTime>
   <UserName>Naam</UserName>
   <Password>xxxxx</Password>
   <ScreenName>Digit</ScreenName>
   <Gpslat>52.30725</Gpslat>
   <Gpslong>6.239371</Gpslong>
   <City>Vught</City>
   <Website>wwwhekkers.net</Website>
   <WebCamPicUrl>wwwhekkers.net/cam.jpg</WebCamPicUrl>
   <Title>Digit's Online Home</Title>
        <UTCTimeZone>0</UTCTimeZone>
</Init>
<Entry>
   <Name>Outside Temperature</Name>
   <ID>1</ID>
   <Units>C</Units>
   <Value>10.7</Value>
</Entry>
<Entry>
   <Name>Outside Humidity</Name>
   <ID>1</ID>
   <Units>%</Units>
   <Value>70</Value>
</Entry>
<Entry>
   <Name>Energy Today</Name>
   <ID>1</ID>
   <Units>kWh</Units>
   <Value>12.042</Value>
   </Entry>
<Entry>
   <Name>Water Today</Name>
   <ID>1</ID><Units>L</Units>
   <Value>443</Value>
</Entry>
<Entry>
   <Name>Gas Today</Name>
   <ID>1</ID>
   <Units>m3</Units>
   <Value>4.78</Value>
</Entry>
</BWired>
<b>You can mail me a sample XML with username and password etc for uploading, I will authorize you.</b>
Only 1 <ENTRY></ENTRY> is needed for uploading, but you send as many in the XML as you want, they will all show up within the marker on googlemaps.
Gps Lat and Long dont have to be accurate if privacy matters!

Check your Lat Long coordinates at:
http://www.gorissen.info/Pierre/maps/go ... cation.php

The <b><ID></b> for each sensor is used for sorting the data within the element <b>and has to be unique</b>

<b>Lenght and type of the XML elements:</b>
Username, varchar 30, mandatory
Password, varchar 20, mandatory
Devicename, varchar 40, mandatory
Units, varchar 25
Value, varchar 30, mandatory
Screenname, varchar 30, mandatory
Website varchar 100
Webcampicurl varchar 100
Title, varchar 50, mandatory
City, varchar 35, mandatory
All datefields are Datetime
Gpslat, Double 30, mandatory
Gpslog, double 30, mandatory
Sortid, integer 11,mandatory
UTCTimeZome, integer, (for example -2, -1, 0, 1, 2, 3 etc)

Below some ASP code sample on how to upload to the bwired webservice
the XML is put in a string as you can see below. The XML is not complete in the sample below, but just a small piece!
Code: Select all
<%
url = "http://www.bwired.nl/Bwiredservice/receive.asp"
information = "<?xml version='1.0' encoding='utf-8'?<BWired><Init><DateTime>01-03-2009 23:59:12</DateTime></Entry></BWired>"

Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send information
%>
It's a asynchronous web service so you are not getting a result back.
This way it's very low on your resources as well. If the Bwired webservice is not available your system just checks a few seconds and the it will stop and tries it again the next round!
I did some testing with Digit and he created as first user the send service within his home automation system and this was running directly!
Best is to upload once every hour the data!

<u><b><font size="2"><b>UPDATE AVAILABLE SCRIPTS FOR UPLOADING (check also topics below):</b></font id="size2"></b></u>

<b><font size="2">Homeseer Xml2Bwired configuration tool:</font id="size2"></b>
Download Attachment:
The manual: http://www.jphuddlestone.co.uk/xml2bwir ... Bwired.pdf
The Tool: http://www.jphuddlestone.co.uk/xml2bwir ... Bwired.zip

<b><font size="2">Script for Perl:</font id="size2"></b>
Download Attachment:
uploaded/Jfn/2009313221156_xml.pl.txt
uploaded/Jfn/2009314164450_XML.zip

<b><font size="2">Domotiga supports the Bwired uploadservice:</font id="size2"></b>
http://www.domotiga.nl/projects/domotiga

<b><font size="2">Script for Synology DS207+ :</font id="size2"></b>
Check the on page 3 the topic from ddgiel for script

<b>DOT.NET C# .net 2.0 / 3.5 sample project (Visual Studio 2008 solution) from Dutchnomad (topic below)</b>
Download Attachment:
uploaded/Bwired/2009330173610_Send2Bwired.zip

<b>Simple Bwired Webservice multi-threaded class for Girder 5</b>
Download Attachment:
uploaded/mhwlng/2009410182129_bwired.zip

Image
User avatar
Bwired
Administrator
Administrator
 
Posts: 5247
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Digit » Fri Mar 13, 2009 8:53 pm

For those who have already started coding right away to "get mapped" [8D], here's how POSTing can be done with .NET:
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
The examples should get you going in a matter of minutes.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Jfn » Fri Mar 13, 2009 10:13 pm

<b>UPDATE: I attached a ZIP file containing two perl scripts that I am currently using to post data to the Bwired website.
The first script generates the .XML file, outputting data to STDOUT, the second one uses the output of the first script to post the data.</b>

Linux users that wish to start coding, see attached perl-script for an example on how to create the following output:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

<BWired>
  <Init>
    <DateTime>13-3-2009</DateTime>
    <UserName>USERNAAM</UserName>
    <Password>PASSWORD</Password>
    <ScreenName>Jfn</ScreenName>
    <Gpslat>52.3</Gpslat>
    <Gpslong>6.2</Gpslong>
    <City>s-Hertogenbosch</City>
    <Website>wwwsesamstraat.nl</Website>
    <Title>Jfn's Online Place</Title>
  </Init>
  <Entry>
    <Name>Outside Temperature</Name>
    <ID>1</ID>
    <Units>C</Units>
    <Value>10.7</Value>
  </Entry>
</BWired>
The script is not yet finished (All data is still hard-coded and not all entries have been added yet), but it should give you an idea on how to generate the XML formatted data.

@Pieter: When the scripts is finished I will ask for a username and password. I will have available weatherdata only.

<b>Download Attachment:</b> [url="http://www.domoticaforum.eu/uploaded/Jfn/2009313221156_xml.pl.txt"][img]images/icon_paperclip.gif[/img] xml.pl.txt[/url]<br />2.07KB

<b>Download Attachment:</b> [url="http://www.domoticaforum.eu/uploaded/Jfn/2009314164450_XML.zip"][img]images/icon_paperclip.gif[/img] XML.zip[/url]<br />1.91KB
Jfn
Member
Member
 
Posts: 332
Joined: February 2008
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Rene » Sat Mar 14, 2009 11:10 pm

To upload data from within Homeseer follow these steps:

1. Create an event:
Image

2. Create the trigger for the event:
Image

3. Create the action for the event:
Image

Open the script window and paste the folling lines in it:
Imports System.IO
Imports System.Net
Imports System.Text

Sub Main(ByVal parms As Object)
const url = "http://www.bwired.nl/Bwiredservice/receive.asp"
const name="Rene" <---REPLACE THIS WITH YOUR INFO (username)
const passwd="password" <---REPLACE THIS WITH YOUR INFO (password)
const city="Vught" <---REPLACE THIS WITH YOUR INFO
const gpslat="53.567878" <---REPLACE THIS WITH YOUR INFO
const gpslong="5.567788" <---REPLACE THIS WITH YOUR INFO
const screenname="RKlootwijk" <---REPLACE THIS WITH YOUR INFO
const title="Rklootwijk Home" <---REPLACE THIS WITH YOUR INFO
const website="www.test.nl" <---REPLACE THIS WITH YOUR INFO or blank
const webcampage="www.test.nl/camimage.jpg" <---REPLACE THIS WITH YOUR INFO or blank

const temp ="[1" <---REPLACE THIS WITH YOUR ID
const humid = "ID of your humidity sensor" <---REPLACE THIS WITH YOUR INFO
const baro = "ID of your barometer" <---REPLACE THIS WITH YOUR INFO
const wind = "ID of your wind speed meter" <---REPLACE THIS WITH YOUR INFO
const power = "ID of your Power usage" <---REPLACE THIS WITH YOUR ID
const Gas = "ID of your Gas usage" <---REPLACE THIS WITH YOUR ID
const Water = "ID of your Water meter" <---REPLACE THIS WITH YOUR ID

dim myXML
dim xmlhttp

myXML = hs.CreateStringClass
myXML.Add("<?xml version=""1.0"" encoding=""UTF-8"" ?>")
myXML.Add("<BWired>")
myXML.Add("<Init>")
myXML.Add("<DateTime>" & Now() & "</DateTime>")
myXML.Add("<UserName>" & name & "</UserName>")
myXML.Add("<Password>" & passwd & "</Password>")
myXML.Add("<ScreenName>" & screenname & "</ScreenName>")
myXML.Add("<Gpslat>" & gpslat & "</Gpslat>")
myXML.Add("<Gpslong>" & gpslong & "</Gpslong>")
myXML.Add("<City>" & city & "</City>")
myXML.Add("<Website>" & website & "</Website>")
myXML.Add("<WebCamPicUrl>" & webcampage & "</WebCamPicUrl>")
myXML.Add("<Title>" & title & "</Title>")
myXML.Add("</Init>")

myXML.Add("<Entry>")
myXML.Add("<Name>Outside Temperature</Name>")
myXML.Add("<ID>1</ID>")
myXML.Add("<Units>C</Units>")
myXML.Add("<Value>" & CStr(hs.DeviceValue(temp) / 10).Replace(",", ".") & "</Value>")
myXML.Add("</Entry>")

myXML.Add("<Entry>")
myXML.Add("<Name>Outside Humidity</Name>")
myXML.Add("<ID>2</ID>")
myXML.Add("<Units>%</Units>")
myXML.Add("<Value>" & hs.DeviceValue(humid) & "</Value>")
myXML.Add("</Entry>")

myXML.Add("<Entry>")
myXML.Add("<Name>Wind Speed</Name>")
myXML.Add("<ID>3</ID>")
myXML.Add("<Units>m/s</Units>")
myXML.Add("<Value>" & CStr(hs.DeviceValue(wind) / 10).Replace(",",".") & "</Value>")
myXML.Add("</Entry>")

myXML.Add("<Entry>")
myXML.Add("<Name>Barometer</Name>")
myXML.Add("<ID>4</ID>")
myXML.Add("<Units>hPa</Units>")
myXML.Add("<Value>" & CInt(hs.DeviceValue(baro) / 100) & "</Value>")
myXML.Add("</Entry>")
myXML.Add("</BWired>")

xmlhttp = WebRequest.Create(url)
xmlhttp.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(myXML.Value)
xmlhttp.ContentType = "text/xml"
xmlhttp.ContentLength = byteArray.Length
Dim dataStream As Stream = xmlhttp.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = xmlhttp.GetResponse()
response.Close()

myXML.Reset
End Sub


Note: When you do not have all these sensors or do not want to upload the data, you can remove cor add data for a specific sensor by deleting or adding the lines for this sensor starting with <Entry> and ending with </Entry>, e.g.:

myXML.Add("<Entry>")
myXML.Add("<Name>Barometer</Name>")
myXML.Add("<ID>4</ID>")
myXML.Add("<Units>hPa</Units>")
myXML.Add("<Value>" & CInt(hs.DeviceValue(baro) / 100) & "</Value>")
myXML.Add("</Entry>")

You could also add other sensors by adding these type of lines for that specific sensor.

Rene.
User avatar
Rene
Global Moderator
Global Moderator
 
Posts: 1678
Joined: October 2008
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Digit » Sat Mar 14, 2009 11:49 pm

This is great!!! [8D]
Who's next? [:D][:D]
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Rene » Sun Mar 15, 2009 12:01 am

Pieter, whats happening. I get the following error when requesting http://www.bwired.nl/domoticaworld.asp:
ADODB.Recordset error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/domoticaworld.asp, line 289

Rene.
User avatar
Rene
Global Moderator
Global Moderator
 
Posts: 1678
Joined: October 2008
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Digit » Sun Mar 15, 2009 12:10 am

Don't worry, it happened before. I think it has to do with the date change and a SELECT that doesn't return any rows (just guessing ofcourse) in Pieters page. Just keep on uploading.
User avatar
Digit
Global Moderator
Global Moderator
 
Posts: 3388
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Bwired » Sun Mar 15, 2009 1:12 am

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by rklootwijk</i>
<br />Pieter, whats happening. I get the following error when requesting http://www.bwired.nl/domoticaworld.asp:
ADODB.Recordset error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/domoticaworld.asp, line 289

Rene.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">I do a select on date = now, and when there is nothing uploaded yet for that day the query is not selecting any records.
I will make some changes on that part.
Really great its all working now!
Thanks for the HS script, hope a lot will follow so we get a great picture on googlemaps.

Jfn has a working Perl script which is working perfectly also.
Thanks all!
User avatar
Bwired
Administrator
Administrator
 
Posts: 5247
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby TANE » Sun Mar 15, 2009 9:01 am

I have the script running without any error in Homeseer. I don't see any data online
User avatar
TANE
Forum Moderator
Forum Moderator
 
Posts: 4807
Joined: April 2007
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Rene » Sun Mar 15, 2009 9:39 am

@Chak: When you add the following line to the script it will also email the XML to you so you can check the correct formatting of the XML:
hs.SendEmail(<your email address>,<your email address>,"test",myXML.Value)




Rene.
User avatar
Rene
Global Moderator
Global Moderator
 
Posts: 1678
Joined: October 2008
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Bwired » Sun Mar 15, 2009 10:51 am

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Chak</i>
<br />I have the script running without any error in Homeseer. I don't see any data online
User avatar
Bwired
Administrator
Administrator
 
Posts: 5247
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Bwired » Sun Mar 15, 2009 10:59 am

Ok check your Lat Lang coordinates at:
http://www.gorissen.info/Pierre/maps/go ... cation.php
There are more way's to do this and within the above link you sure to get the right ones.
User avatar
Bwired
Administrator
Administrator
 
Posts: 5247
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Noel » Sun Mar 15, 2009 11:06 am

What password should be used?
The one from the forum?

--
Image
User avatar
Noel
Senior Member
Senior Member
 
Posts: 1881
Joined: February 2008
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Bwired » Sun Mar 15, 2009 11:16 am

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by wifi</i>
<br />What password should be used?
The one from the forum?

--
Image
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">Just make one up and try, I see the XML coming in and you to the list and then it will work! Or mail me offline for this.
Please when you have no second thoughts about it upload some power, water and gas usage as well. You can add as many <ENTRY> as you wish.

I'm thinking about selling this data to the highest bidder [:D][:D]
User avatar
Bwired
Administrator
Administrator
 
Posts: 5247
Joined: March 2006
Location: Netherlands

Bwired Googlemaps upload data webservice

Postby Noel » Sun Mar 15, 2009 11:21 am

The difference here is that I know what data I'm giving away, and that I have 100% control over it :-)
At the moment I'm getting an error: <blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Error Running script, script run or compile error in file: xml2bwired.bv1006:Expected ')' in line 5 More info: Expected ')' <hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"> when I use "rklootwijk's" script :-(

--
Image
User avatar
Noel
Senior Member
Senior Member
 
Posts: 1881
Joined: February 2008
Location: Netherlands

Next

Return to Bwired Forum

Who is online

Users browsing this forum: No registered users and 0 guests