I’ve been playing around with an API to get data from my smart meter for gas and electricity. There’s a free API provided by these folks (https://glowmarkt.com/) which seems to work pretty well and gives me data up to the end of the previous day.
I’ve ordered one of their devices for £69 which should connect to most any uk smart meter and give live readings every 10s for electricity and 30m for gas. I’ve been teaching myself JavaScript and looking into how to create homey apps and I’m planning to have a go at integrating this device as a source of whole house electricity and gas usage info plus live unit pricing etc for the uk market.
Any interest in this / anyone else tried something similar?
2 Likes
For Holland this is done many times, search for P1, this is the universal name for the connection from the smart meter here.
Just registered for bright myself, going to look if there’s a way to push the values out to JS in homey or use mqtt in some way!
I’ve not played with the MQTT yet but the API works well and is very easy to use. Using advanced flow it’s pretty straight forward to get the data into homey. One main reason for me that i wanted an app is to make the data appear as a whole house smart meter in the energy tab in homey. That way it automatically treats that as the total house consumption and creates an ‘other’ category with all the other energy meter readings from individual devices subtracted from the smart meter reading.
I’ve got this working now in my test app but right now the API keys and so on are hard coded in! So lots of work left to build the pieces that will get meter ids via the api in the app, allow the app to manage the api key from username and password and so on. Taking time as I’m having to teach myself JavaScript as I go so it’s going to be quite a project for me. But the proof of concept is there.
3 Likes
Nice, I’ve bought a few JS and Node.JS books myself, is there any resources you’ve used you’ve found helpful? I’m finding it difficult with the app development side but wondering if I’m jumping in the deep end too quick. Is your code open source for the app you’ve done so far?
Think I’ll try with the MQTT and advanced flow to start with! Perhaps an advanced virtual device may allow updates and the ability to show as a smart meter?
The book I am using to learn JavaScript is “JavaScript: The Definitive Guide” from O’Reilly, which seems pretty good and has chapters on node and asynchronous. I found the developer series videos on Homey YouTube channel helpful too to get started with app development.
I am just working out how to get GitHub connected up with VS Code so I can manage the code in a repository. I also need to work out a way to make the authentication work without having to have my username and password hard coded into the app which was my very hacky way to get the proof of concept working. Once I’ve got those sorted, I will make the repository public and keep developing from there.
I did also wonder whether an advanced virtual device would work but I also kinda wanted to try writing an app so I’m going down that path for now. I think the MQTT + advanced flows approach would be doable as well. Who knows, if I really get handy with the JavaScript maybe I can add that to the app later.
1 Like
Thanks for the heads up, will take a look!
Keep us updated and I’ll let you know how I get on when I get a chance to try a few things!
Good luck!
You can store them in the env.json file and don’t publish that to GitHub. The format of the file is standard json with key: value pairs.
I am just working out how to get GitHub connected up with VS Code.
There are plugins for github in VS Code.
Thanks @Adrian_Rockall i have made some good progress today and got GitHub working with vs code. I think I’m well on the way now also to be able to sort the username and password issue. The challenge there was that I can’t use the env.json since each user will need to create their own account for the glowmarkt api and then enter their username and password into this app in order for it to connect and read their smart meter data. But Arie has very helpfully pointed me in the right direction to use the device store for this in another thread I opened on this question How to securely store username and password for an API within my app - #12 by DaneedeKruyff
2 Likes
Hi @Jonathan_Draper - how are you getting on with this?
Happy to collaborate with you if you like - I’m looking for this exact plugin, and it’ll save me writing it myself
Hi @alistair I would love to collaborate. Especially if your JavaScript skills are better than mine! Sadly no further progress yet. Work and then Christmas and now other problems with my homey have all got in the way. Hopefully I can take another look next month. I worked out how to use GitHub to host the code but it’s still got my authentication details hard coded into the app as I never got any clear answer on other threads about how to securely handle authentication details per user so I think I need to find some solution for that before I can share access to the code.
1 Like
Hi @alistair and @Nigel_Scott if you’re still interested I finally got around to learning enough JavaScript to get this working and my first Homey app went live today supporting live electricity usage via the API for now. Next I’m planning to add current tariff information as well.
1 Like
Hello Jonathan
I have your app installed and it works a treat.
Would there be a way to get my Gas Meter connected, so i could get the gas consumption.
That would be the icing on the cake for me.
Hi Brian. I did look into it but it’s not trivial. For gas the smart meter only reports the overall meter reading and not any form of ‘current rate of consumption’ so it’s not nearly as useful to have in homey I think and it’s also in strange units that need converting in a non trivial way. Finally there’s no suitable standard unit supported in homey so I’d have to create a custom capability for it.
All of which I think should in theory be doable and perhaps for a more experienced coder maybe fairly easy. But since I’m not that experienced and it didn’t seem that useful and I’ve got a lot on at the moment, I’ve not got round to it.
Thank you very much for the reply.