Tools for getting your Octopus Energy electricity data into a SQLite database, for exploration in Datasette.
- Install the dependencies:
pip install -r requirements.txt - Find your API key, serial number and MPAN from https://octopus.energy/dashboard/developer/
- Rename
.env-exampleto.envand fill in the details - Fetch all your historic data with
python all.py. This may take a few minutes - Get daily updates with
python daily.py - Use Datasette to explore your data:
datasette readings.db
select
strftime("%m-%Y", start_time) as 'month-year',
sum(usage) as monthly_usage
from readings
group by strftime("%m-%Y", start_time);select
strftime("%m-%Y", start_time) as 'month-year',
avg(usage) as avg_usage
from readings
group by strftime("%m-%Y", start_time);select
strftime("%m-%Y", start_time) as 'month-year',
avg(usage) as avg_usage
from readings
where strftime("%w", start_time) = "1"
group by strftime("%m-%Y", start_time);select
strftime("%H", start_time) as time,
avg(usage) as avg_usage
from readings
group by strftime("%H", start_time);select
strftime("%Y-%m-%d", start_time) as Date,
case
cast (strftime('%w', start_time) as integer)
when 0 then 'Sunday'
when 1 then 'Monday'
when 2 then 'Tuesday'
when 3 then 'Wednesday'
when 4 then 'Thursday'
when 5 then 'Friday'
else 'Saturday'
end as Day,
cast(sum(usage) as integer) as Usage
from
readings
where
date(start_time) >
date('now', '-8 day')
group by
strftime("%Y-%m-%d", start_time);