Skip to content
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

My first project. #8

Open
Chipgit opened this issue May 28, 2020 · 9 comments
Open

My first project. #8

Chipgit opened this issue May 28, 2020 · 9 comments

Comments

@Chipgit
Copy link

Chipgit commented May 28, 2020

Many thanks.

This was my first Pi project and although it's still work in progress it's been an amazing journey.

I've added the use of a weather API to bring in live weather data to fill in the display.

Added code to deal with negative pricing and displays this as a black outlined clear blocks on the graph.

Also displays the cheapest 2hr block to use dish washers, washing machines etc.

Printed a 3d case.

15906928130571759282277467555134

15906928650148457506243741394825

@pufferfish-tech
Copy link
Owner

That looks amazing, is that the bigger version of the display from pimoroni?

@Chipgit
Copy link
Author

Chipgit commented May 28, 2020

Yeah. The inky what

Loads of work to do with the weather side of it. Layout needs some work.
But made up with it as a little project.

@ukblaster
Copy link

That looks impressive. I was pondering myself about writing something to work out the cheapest 3hr block strangely as I forever work out best time to run the dishwasher.

@Chipgit
Copy link
Author

Chipgit commented Jul 4, 2020

IMG_20200619_105934

Thanks. The cheapest 2 hours, 3 hours is pretty easy to do.
I'm no coder, this was my first raspberry pi project.

No idea how to use GitHub either to be honest to upload it.

I've got negative pricing sorted and can also graph it with an outline, not black or red.
Also managed to get the weather logos sorted.
After messing around with icons and images, I scrapped it and used a weather font which was so easy..

I've added a API call for prices upon reboot in case it's been off for a day or more.
Also tweaked that call if prices are not available as sometime they are not until 5pm or even later.

Still some tweaking to go, have loads of weather choices, not sure I need a min temp forecast.

When I'm actually on the tariff (hurry up smart meter) I think I can call the API for my last half hours useage, which I plan to.

IMG_20200605_183849

@pufferfish-tech
Copy link
Owner

pufferfish-tech commented Jul 4, 2020

You're not the only one who doesn't know how to use github!!

It's not that hard to get some code on. I haven't a clue about the rest of the features though, every time I try to learn git my brain drifts off, I don't know why. I think there's a lot of unusual terminology that I can't work out.

I've coded something for usage already in django so give me a shout if you need any of it. It's not that hard, the only pain is that it's half hourly and dealing with that is really annoying.

response = requests.get('https://api.octopus.energy/v1/electricity-meter-points/<account_id>/meters/<meter_id>/consumption/?page_size=1000', auth=('<key_here>','null') )
	meterdata= response.json()
	print(meterdata['count'])
	print(meterdata['results'][0])
	for result in meterdata['results']:
		print(result['consumption'])	
		consumption_item = consumption_data(consumption_value=result['consumption'],bucket='1',temporal_reference= result['interval_start'])
		consumption_item.save()

That's the bit to store your consumption for the last 1000 "half hours".
Django has a sort of thing where you can create a database object "consumption_data" so you don't have that in bare python, if that makes sense, you just have to store them separately.

Oh, some bad news though - the octopus API pretty much updates meter usage as and when it feels like it, around 5pm every day for the day before's usage. So, if you want live usage, well, I've managed it myself but using an energyhive/efergy clip on energy monitor..using their API. Which is really smart. That's a whole kettle of worms though, has nothing in common with octopus energy. How did you manage to upload a photo btw?

I assume you know where the API reference is -> https://octopus.energy/dashboard/developer/

@graydon2212
Copy link

I would really like to change the cheapest price on the standard Inky pHAT to point me to the beginning of the cheapest 3 hour period. I'm no coder either, and I can't begin to work it out!!

@pufferfish-tech
Copy link
Owner

I would really like to change the cheapest price on the standard Inky pHAT to point me to the beginning of the cheapest 3 hour period. I'm no coder either, and I can't begin to work it out!!

You could ask @Chipgit if he can upload his code, I had a look at his forked repository but either it doesn't show the code for the "cheapest 2 hours" or...I'm being dumb. Possibly the latter.

@Chipgit
Copy link
Author

Chipgit commented Nov 2, 2020

I would really like to change the cheapest price on the standard Inky pHAT to point me to the beginning of the cheapest 3 hour period. I'm no coder either, and I can't begin to work it out!!

You could ask @Chipgit if he can upload his code, I had a look at his forked repository but either it doesn't show the code for the "cheapest 2 hours" or...I'm being dumb. Possibly the latter.

You're right.

Not used this before.
I'm been busy with stupid lock down work...

I'm been messing around with the layout and function.
It now displays usage to keep an eye on previous days.
The graph scales automatically if no prices are over 25p etc.
Negative prices as a non filled box etc.

I'll get round to updating shortly.

image

The code for finding out the cheapest 2hr period is below.
pricesonly is from the original code (prices) with the zeros removed(end of data) which is a list of the next 30 segments excluding zeros ones at the end.

pricesonly = [i for i in prices[:48] if i != 0 ] # Removing Zero Prices with max 24hrs returned

Initially just creates a new list of 4 added together, then gets the "min" value, and the time.
Easy to change to 3hrs. Change the -3 to -5 so it's the last lot of 6 valid values. and add index+4 and +5 to the cost.

pricechunk = []
for index, price in enumerate(pricesonly):
if index < (len(pricesonly)-3):
chunk=pricesonly[index]+pricesonly[index+1]+pricesonly[index+2]+pricesonly[index+3]
pricechunk.append(chunk)
minimumchunk = min(pricechunk)

cheapestChunkIndexs = []
for index, chunk in enumerate(pricechunk):
if (chunk == minimumchunk):
cheapestChunkIndexs.append(index)

Code to display the above

min_offset = pricechunk.index(minimumchunk) * 30
time_of_cheapest = the_now + datetime.timedelta(minutes=(min_offset+60))
end_time_of_cheapest = the_now + datetime.timedelta(minutes=(min_offset+180))
draw.text((0,74), " Cheapest 2hrs - " + ("{0:.1f}".format((minimumchunk)/4)) + "p ave @ " + (str(time_of_cheapest.time())[0:5]) + "-" + (str(end_time_of_cheapest.time())[0:5]), inky_display.BLACK, ImageFont.truetype(FredokaOne, 20))

@pufferfish-tech
Copy link
Owner

It seems like a good thing to have so I'll try to merge it into the code...adding up groups of 2n (n=time period required) and looking for the min...now that is a cool way of doing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants