[vz-users] [vz-dev] iskra mt171

Thorben Thuermer r00t at constancy.org
Thu Jan 10 16:55:08 CET 2013


On Thu, 10 Jan 2013 16:03:52 +0100
Henry van Gestel <henry.van.gestel at gmail.com> wrote:
> I think I understood what and where I should enter the date and avoid
> using vzlogger. So I extend my Perl script with putting or POST data to the DB.
> 
> Trying to get that data from my Perl into Mysql DB I am getting the following
> result ( example from http://wiki.volkszaehler.org/development/api/reference)
> 
> POST http://192.168.0.187/volkszaehler.org/htdocs/middleware.php/data/a301d8d0-903b-1234-94bb-d943d061b6a8.json?ts=1284677961150&value=12
> [1] 5749
> pi at raspberrypi ~/Iskra_read $ Please enter content (application/x-www-form-urlencoded) to be POSTed:
> (no prompt returning)
> 
> Must be something I didn’t read or understood?, Do you  know what I miss?

you have no idea what you are doing,
that's so wrong i don't really know where to start explaining...

- POST is the http method to be used, not a command.
  just to confuse people like you, there is also a program named 'POST' in
  some perl package. this program asks you to enter the data to be POSTed.
  but most likely you want to use wget or curl.
  (or just code inside your perl script)
-  you are passing the url to the program through a unix-shell.
   in such a shell, some characters have spacial meanings,
   and need to be quoted or escaped when passing them as part of strings.
   one of those characters is the ampersand ('&'), which ends the current command,
   runs it in the background, and starts a new one...
   which is why you get "no prompt returning" (actually the prompt is right there,
   BEFORE the prompt of POST, which you can't answer because POST was put in the
   background.)

also, you can avoid having to use POST by adding method=add to the url,
as i gave it in my example.

so, this will work:
$ curl 'http://192.168.0.187/volkszaehler.org/htdocs/middleware.php/data/a301d8d0-903b-1234-94bb-d943d061b6a8.json?method=add&ts=1284677961150&value=12'

or, using POST:
# curl --post-data "ts=1284677961150&value=12" 'http://192.168.0.187/volkszaehler.org/htdocs/middleware.php/data/a301d8d0-903b-1234-94bb-d943d061b6a8.json'

> Question about timestamp, why is timestamp in absolute value and not in a readable format?

this is an API for computers talking to other computers.
there is no need to keep the timestamp human-readable.
(consider that one of the clients for the middleware is ethersex on an 8-bit
 microcontroller, which hardly has the processing power to handle date strings)
the time is passed as a unix-timestamp with milisecond-precision.
you can convert it like this (remove the last 3 digits, which are the miliseconds):
$ date -d @1284677961 #150
Fri Sep 17 00:59:21 CEST 2010

> thks
> Henry

- T.

> On Jan 9, 2013, at 10:00 AM, Thorben Thuermer wrote:
> 
> > On Tue, 08 Jan 2013 14:40:09 +0100
> > Henry van Gestel <henry.van.gestel at gmail.com> wrote:
> >> Questions:
> >> 1)
> >> Do you know what the datamodel is (name of fields and format) , what 
> >> schould I sent : timestamp, used KW, produced kw, PV generated KW?
> > [...]
> > you have to create a separate channel for each value.
> > the middleware stores tuples of (channel,timestamp,value).
> > (both via the api, and in it's sql database.)
> > 
> >> 2)
> >> Where is the calculating taking place as I sent only status values at 
> >> that time (every 5 minutes)?
> > 
> > what calculating?
> > the middleware stores the data as reported,
> > the frontend loads the data from the middleware,
> > (i guess a total/average is calculated in the process)
> > and displays it...
> > 
> >> Henry
> > 
> > - T.
> > 
> >> Op 1/8/2013 8:41 AM, Thorben Thuermer schreef:
> >>> Hello,
> >>> 
> >>> so you want to use the middleware/frontend to store/visualize your data,
> >>> but can't use vzlogger to import it.
> >>> (the prefered fix would ofcourse be to fix vzlogger to work with your
> >>>  meter! maybe if you give us the details of how you made it work,
> >>>  i.e. which timings are critical etc., we can fix hat for you...)
> >>> 
> >>> but there are two alternatives:
> >>> - send the data to the middleware API from your script.
> >>>   the api is quite simple, and documented:
> >>>   http://wiki.volkszaehler.org/development/api/reference
> >>>   (in german, if that's a problem, please complain!)
> >>>   basically all you need is:
> >>>   http://.../middleware.php/data/<uuid>.json?operation=add&value=<value>
> >>> 
> >>> - insert the data directly into the middleware's database,
> >>>   no need to put it into an intermediate database first.
> >>>   the format is relativey simple, just look at the database
> >>>   after installing the middleware (and maybe loading the test data).
> >>> 
> >>> - T.
> >>> 
> >>> On Tue, 8 Jan 2013 00:35:41 +0100
> >>> Henry van Gestel <henry.van.gestel at gmail.com> wrote:
> >>>> Maybe somebody can help me.
> >>>> I am strugling now how to continue , I am be able to get the data from 2
> >>>> Iskra MT171 meters .
> >>>> 
> >>>>> I also can put the data in a Mysql DB wondering what data model is used.
> >>>>> e.g timestamp, actual value used , actual generated , PV_collected.
> >>>> A) I wonder where various values like  the avg, max , min is calculated?
> >>>> 
> >>>> B) Maybe somebody can give me a hint or a detailed description of vzlogger
> >>>> where and what it is doing.
> >>>> 
> >>>> Or
> >>>> 
> >>>> How to let vzlogger get the data from sql stored data or a file.
> >>>> 
> >>>> Configuration:
> >>>> I have 2 ir heads (from Udo) connected to Rpi, a perl script reads the 2
> >>>> heads every 5 minutes, puts data in a mysql dB e.g  fields are (Timestamp,
> >>>> headnr, PV_produced, normal_tarrif_used, norma_tarrif_produced).
> >>>> 
> >>>> Rgrds
> >> 
> 


More information about the volkszaehler-users mailing list