Page 1 of 1

REST api to access SQL?

PostPosted: Tue Feb 09, 2016 3:10 am
by moyse
Specifically, I want to plot the historical temperature values etc.

Is there any way to do this? I started to write a django app, but thought perhaps I should ask first!

Re: REST api to access SQL?

PostPosted: Fri Feb 19, 2016 7:15 am
by DaveL17
Somehow, I missed your question.

I'm not sure about using REST to do what you suggest, but here's my workaround. I have a script that runs in Indigo every 15 minutes which saves select data to a CSV file and then fires Gnuplot scripts to create PNG charts. I run another script (daily) which prunes the CSV file to length to ensure that it doesn't grow too large (with the exception of weather data, my range is three days' worth.) I've been very happy with this approach.

Recent versions of my scripts are on the forums and can be found in my developer thread here: http://forums.indigodomo.com/viewforum.php?f=148

Here's a couple examples of the output:
temperaturesOutdoor.png
temperaturesOutdoor.png (15.24 KiB) Viewed 2694 times

10DayForecast.png
10DayForecast.png (14.64 KiB) Viewed 2694 times

Re: REST api to access SQL?

PostPosted: Fri Feb 19, 2016 7:57 am
by kw123
As Dave mentioned there are many ways to do this
There are the gnu plot, mat plot indigoplotd etc solutions
But getting a this through the restful api is a nice challenge
I might consider this once I am done with my pibeacon plugin.


Sent from my iPhone using Tapatalk

Re: REST api to access SQL?

PostPosted: Mon May 02, 2016 1:31 pm
by moyse
Hi all,

Yes, I've used indigoplotd Karl - thanks very much! For a few reasons it's not exactly what I want though. Ditto for Dave (thanks too!) I want something I can use with a responsive frontend (I'm teaching myself React.js).

I've now got more wrapper more-or-less working as I want and so I've uploaded it to pypi: https://pypi.python.org/pypi?:action=display&name=django-indigorestwrapper&version=0.6 and github https://github.com/EdwardMoyse/django-indigorestwrapper just in case it could be of use to anyone else.

You can do things like:
- get a list of devices (with more info than the equivalent from Indigo)
- get complete information about a device, using the device id (i.e. instead of using the name as in indigo)
- get the history of the device.

Another benefit (for me) is you have a lot more flexibility in the authentication schemes you can use (I'm using token based myself, but you can use anything which is provided by or for django-rest-framework: http://www.django-rest-framework.org/ap ... ntication/)

There's a lot more in the documentation, but the sort of things it lets you do are e.g. show the temperature of a sensor (this is a react frontend I'm working on, so it's all dynamic)

Temperature.png
Temperature.png (213.34 KiB) Viewed 2611 times


Anyway, I hope it might be of use to someone else - and if it would help to add functionality, let me know. I think most of the hard work is done now.

Re: REST api to access SQL?

PostPosted: Mon May 02, 2016 1:52 pm
by DaveL17
That's pretty cool! Nice work.


Sent from my iPhone using Tapatalk