-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script for adding in retrospective data (using mysql/maria) #378
Comments
Thank you for writing this |
Thanks for writing this script. I'm a home assistant novice and keen to give this a try to resolve my inaccurate energy data. |
I can answer the first part of your question, I used this guide to get resource_id, application_id an token which allowed me to run the script. |
I don't see any reason it wouldn't work for gas? I live off gas grid, so
can't try myself.
…On Tue, 30 Jan 2024, 22:42 biggeeus, ***@***.***> wrote:
Thanks for writing this script. I'm a home assistant novice and keen to
give this a try to resolve my inaccurate energy data. I've worked out which
metadata_id I need, but I'm struggling to work out where to look for my
resource_id, application_id and token. Any help greatly appreciated. Also,
I'm running the standard SQLite db, so does the script need modifying for
this? Secondly, if I get it working for my electricity, can I change the
metadata_id and resource_id to also run the script for my gas in the same
way. Apologies for all the questions.
I can answer the first part of your question, I used this guide to get
resource_id, application_id an token which allowed me to run the script.
https://glowmarkt.com/home/blogs/extracting-energy-data-from-the-hildebrand-glowmarkt-api-in-5-easy-steps
<http://url>
I too would like to know if I can use it for gas.
—
Reply to this email directly, view it on GitHub
<#378 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABPMBA7LXNY2P6JLKYML6DYRFZL7AVCNFSM6AAAAABAPRB2BKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJYGAZTKMBZGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thanks for the link to the API help guide, since my original post I also discovered the API guide and I managed to get my token, and resource_ids using postman. I've also modified the original script to work with the default sqlite database and I've got it working with my gas usage. I did this by changing the metadata_id and resource_id (passing them in as variables to the script) and it worked just fine. I'm also experimenting with cost data, which seems to work, but I've had to divide the data by 100 and also add in the daily standing charges. I'm still getting a few oddities at the start of the current day, due to the lag in data reporting, but these seem to get mopped up after a day or so. |
Just tried updating my gas and it work great. Is there any reason why I can't run this script every hour, to keep the current day correctly populated, such as a limit on the number of API calls ? |
i found it of little value to do it; i found that the inaccuracies/lag in the glow data that cause the main ha-hildebrand-dcc thing to get gaps in it's data often don't resolve for a good number of hours. but not aware of any reason you couldn't. |
Been running it every hour this morning and I see what you mean, if only I could get a Octopus Home Mini I could use that instead but unfortunately I only have a SMETS1 meter and it doesn't work with it. |
Is there a way to adapt this script to go through an entire month doing the same thing? /Edit: ChatGPT sorted it out for me :) Updates the data for the last 90 days.
|
Noticed that the script (or it could be the source data) doesn't cater for British Summer Time. Usage is showing an hour earlier than it should. |
The DCC energy data is stored and retrieved using UTC time format by the script (without time zone) and the Home Assistant database stores it the same way using a Unix-style timestamp. For me, this works fine during BST because my Home Assistant displays the energy graph usage in my current timezone i.e. BST by offsetting the UTC stored energy data. So no timezone conversion of the actual data is needed. |
Could someone explain how to run this on/within HA please? I've managed to get all the variables for the API and my database added to the script. I've then uploaded it to "/homeassistant/scripts/glow-scrape.py" but when I try to run the commands, I get error "cannot execute: required file not found" The file has execute permissions.
|
My data often doesn't update on the api.glowmarkt.com API this plugin uses for an hour or two; when it does - because this app just uses a sum, you get hours with big peaks on, rather than accurate spread out usage. (I think, from querying other API's; this is caching on glow's side; you can sometimes see more up to date data on different APIs (or in the bright app) than is available on the daily sum).
Anyway - this script will query the hourly data for a day; correct/add it into home assistants statistics and statistics_short_term tables and then update all records ahead of the affected ones so that the statistics add up correctly (HA statistics store a running total; so you need to update records ahead in time of the ones you change).
I've not touched the yearly records; wasn't as interested in them - plus the end result is the same; so they should still tally.
Run it by passing an argument for 'days ago'; or leave blank to do today I've got it running (via ha) as a script every night + have had it like this for a month or so:
Figured it might be of interest/useful to someone.
You need to find/replace in:
Your metadata_id - look in statistics_meta for sensor.electric_consumption_today
Your database credentials
And then fill in the relevant resource_id, application_id and token in place of the '...' bits in requests.get
And back your database up first!
The text was updated successfully, but these errors were encountered: