python code to parse emonhub v8.5 raw php data files available for anyone who cares..

For anyone like me who would far prefer to work in Python in order to extract statistics and make alternative visualisations, I threw some code together to parse the dat and meta files in /home/pi/data/phpfina and spit out tabular text files. I've put it in github at https://github.com/fubar2/emonpi_py

I haven't looked at the latest emonhub code yet, but this was developed for v8.5. which oddly enough is what was supplied as of last week.

Pull requests welcome.

 

TrystanLea's picture

Re: python code to parse emonhub v8.5 raw php data files available for anyone who cares..

Great thanks for sharing fubar. This should work fine for newer versions too as phpfina has not changed.

fubar's picture

Re: python code to parse emonhub v8.5 raw php data files available for anyone who cares..

Updated to include the paho example subscribed to emonhub/rx/5/#

easy!

Now I can deal with legacy data and data going forward.

On to the next step - figuring out hourly consumption compared to predicted solar generation from http://pvwatts.nrel.gov/pvwatts.php.

Idea is to take the hourly spreadsheet of output for your planned pvc system and see what fraction of your day time use (as much as is available at least) will be paid for so you can get a seriously reliable prediction of the rate of return on the pvc setup cost will be.

I'll keep development in that same repository if anyone wants to follow along. 

fubar's picture

Re: python code to parse emonhub v8.5 raw php data files available for anyone who cares..

So now we have a Bokeh strip chart plotter working in real time. It subscribes to the local emonpi mqtt server - I started developing on the emonpi but realised that I can work on my desktop once I'd allowed other machines to connect to the emonpi mqtt server. The code is amazingly simple considering what it's doing.

https://github.com/fubar2/emonpi_py/blob/master/mqtt_bokeh.py

Below is a screen shot but the chart is dynamic of course - updates itself everytime an mqtt message arrives! X axis dates are not right but that's easy to fix. Bokeh is very, very slick...

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.