REST API - Token

Hello,

I wanted to check out the REST API, I tried the example of chapter 3.6 of the manual (realtime data) like this:

curl -v "http://192.168.0.137:8080/sensor/260b2a7e322ef13dd392c8686d39d4bee1?version=1.0&interval=minute&
unit=watt&callback=realtime"

But it tells me this error: "Malformed query string interval, unit and version query parameters are required.", although all these parameters are specified.
Since all other examples include a token, I suspect this has something to do with it. But I can't find this token thing, the manual is rather obscure about this.
So: where can I find this token or is something else wrong?

thanks,

dvrslype

gebhardm's picture

The token is provided in this website's user settings page on the sensors tab; have you tried the URL (http part w/o the curl) directly in a browser? It should return the minute string as text directly (at least for me it worked w/o token); usual question: Is the JSON API switched on in the config? ;-)
Regards
Markus

dvrslype's picture

JSON API is switched on in the device's web interface.

Also tried the reporting to the Flukso website and tried adding my device, but got the "Please specify a valid serial number." error message when adding the device. How can I add my device?

Accessed the device using ssh and inspected the /usr/bin/restful LUA script, where the "Malformed Query" message comes from. Don't understand why the message comes up, though, because all required parameters are given. Please help me out.

gebhardm's picture

On the settings menu in the devices tab add your device in the form FL02000xxx with xxx your FLM's actual number - should be exactly as printed on the FLM's back (note that there seem also FL03yyyyyy and FL01zzzzzz devices - so number is corresponding to your device's...); after that heartbeats are recognized from the FLM website and you can see your configured sensors in the Sensors menu. Fairly straight forward.

dvrslype's picture

Well, that's what I tried, but it gets me the "Please specify a valid serial number." error message as mentioned before. My serial starts with FL2001xxx btw. Still no clue on the tokens.

gebhardm's picture

Try FL02001xxx with an added zero after the FL...

dvrslype's picture

Hmm, excuse me, that was a typo, I indeed tried with the added zero.

icarus75's picture

How did you obtain this FLM? Just asking since some of the FLMs have been re-flashed to report to a server different from flukso.net.

dvrslype's picture

Ow, that may be the cause, yes. I got this in a bundle from 5thplay, but I would like to read the values out myself. Do I need to reflash it (is that allowed) or do I need to buy a new one?

icarus75's picture

No worries. You can reflash the FLM02A by following the instructions detailed in a comment of this forum post. Substitute FLM02-1-4 with FLM02-1-6 to flash the latest firmware version. Send me an email with your FLM's serial number so that it can be provisioned in the database.

dvrslype's picture

I flashed the device in windows (got some 32-64 bit error on linux: ./ap51-flash: error while loading shared libraries: libpcap.so.0.8: wrong ELF class: ELFCLASS64), i think the procedure was successfull. Only thing is, I cannot connect to the device. I see that it does some Gratuitous ARP request for the address 192.168.255.1 (probably to see if this address is available), but after that I cannot connect to it. The device is connected to my laptop (192.168.0.1/16 running dnsmasq dhcp server). Nmapping the subnet does not reveal any device present. What could this be?

Thanks for your help!

icarus75's picture

Have a look at the Fluksometer Manual. By default the FLM is configured in ethernet mode, meaning that it will try to associate with your home wifi and report its readings via this wifi link. The eth port is used for configuration purposes. There's a DHCP server listening on this port. So connect your laptop directly to the FLM eth port. If the laptop is set up as a DHCP client on its eth port (which should be the default on almost all laptops), it will be handed one by the FLM in the 192.168.255.0/8 range. Then point your browser to 192.168.255.1 and you should see the local configuration interface.

ap51-flash was indeed compiled for x86 not x68-64, hence the error.

dvrslype's picture

Thanks, i'm on the webinterface again. I will mail you my serial.