-
Notifications
You must be signed in to change notification settings - Fork 27
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
support for a 3.5 inch display. #25
Comments
Not one to sit idle and wait for solutions to land on my lap i set about working out how to do this. Aided massively (and hindered by) ChatGPT. I broke the problem down into several parts. I needed the site to autoupdate on recieving new data (as the site is what will be on my display) and i needed a way to parse the data from the api curl grab. The scripts are stored in a folder and the webpage is stored in a templates folder in that folder... it makes sense when you look at the code. The website: Current rate:Next rate:
The server.py (this needs to be running all the time. app = Flask(name) current_rate = "Initial Current Rate" @app.route('/') Modify the 'update_rates' event to 'update' in server.py@socketio.on('update_rates') if name == 'main': @socketio.on('connect') @sio.on('disconnect') The client.py... this is what i plan to run via cron every 30 minutes. sio = socketio.Client() @sio.on('connect') def on_connect(): def get_current_value_inc_vat(json_file_path):
def get_value_at_future_time(json_file_path, minutes_offset=0):
def update_rates(current_rate, next_rate): if name == 'main':
` The data.json is in the same folder as the scripts and contains the out put of the curl command to get the rates. bit too long to add here but its the result of the curl command from Unit rates on https://octopus.energy/dashboard/new/accounts/personal-details/api-access I still need to write a script that will run that curl command at 1600 and replace the existing data.json file...but i feel that should be simple enough. I initially tried to host the page seperate from the script but that proved to be a pain from a sockets point of view. I havent looked at pulling current usage or the daily consumption yet, not sure thats possible with the api. Interesting experiement though and something i plan to look more at with time EDIT: i put the files in code togs for github...it doesnt seem to have liked that. but anyone trying to repeat what i did should be able to decode these lol |
I wasnt happy with how the text got mangled above so I created a repo for what I was doing. This includes the .sh for retrieving the prices too I have no idea if this is even remotely helpful to others though lol |
Is your feature request related to a problem? Please describe.
I just purchased a 3.5inch display for a pi 2 model b to display the curerent half hour rate - upcoming rate - current consumption (if the api supports it) - consumption so far on that day (and price....)
The idea was to replace my smart meters out of date monitor that cant show anything beyond current consumption lol
Then I realised I dont know how to do any of that and google lead me here.
Describe the solution you'd like
I would love to be able to display the text like you have it but on a self updating local website hosted on the PI, displayed on the 3.5 inch display. Not sure if such is possible.
Describe alternatives you've considered
sitting in the corner and rocking back and forward slowly.
learning python and how to make a website thats dynamic using python...thats actually a long term thing.
Additional context
I know c#, would be happy to be shown how to get a specific value for the half hour time slot via the api and have it in a variable then pointed in the direction of how to make a website with python that displays that variable on it.... armed with that knowledge i could probably extrapolate the rest.... but i dont know where to begin lol
Your app fills a mysql database, so knowing how to pull a value from that data base and a link to a good noob friendly python website building guide could be all I need?
The text was updated successfully, but these errors were encountered: