badguy99 / octocost Goto Github PK
View Code? Open in Web Editor NEWOctocost is an app which works under AppDaemon within Home Assistant which gets yearly and monthly cost and usage of Octopus Energy Agile Octopus Tariff
License: MIT License
Octocost is an app which works under AppDaemon within Home Assistant which gets yearly and monthly cost and usage of Octopus Energy Agile Octopus Tariff
License: MIT License
Offset from local time can have issues with time being in the past depending on clocks on user systems, when providing the start time to run_every:
2020-04-24 10:44:09.360828 WARNING octocost: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 145, in initialize_app
await utils.run_in_executor(self, init)
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
response = future.result()
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/appdaemon/apps/octocost/octocost.py", line 25, in initialize
self.run_every(self.cost_and_usage_callback, time, 120 * 60)
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 191, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 285, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
raise self._exception
File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 2476, in run_every
raise ValueError("start cannot be in the past")
ValueError: start cannot be in the past
So use run_in / run_hourly etc. instead.
If account id is given, https://api.octopus.energy/v1/accounts/ can be used to get the tariff details, and start end dates e.g.:
tariff_code | "E-1R-AGILE-18-02-21-H" |
---|---|
valid_from | "2020-02-23T00:00:00Z" |
valid_to | "2021-02-23T00:00:00Z" |
gas data is also there.
I using tracker tariff, e.g.
tariff_code | "E-1R-AGILE-18-02-21-H" |
---|---|
valid_from | "2020-02-23T00:00:00Z" |
valid_to | "2021-02-23T00:00:00Z" |
Use the following rather than the normal API, until tracker is added to the normal API:
https://octopus.energy/api/v1/tracker/G-1R-SILVER-2017-1-{grid_code}/daily/current/0/{consumption}/
https://octopus.energy/api/v1/tracker/G-1R-SILVER-2017-1-{grid_code}/monthly/past/{num_months}/{consumption}/
https://octopus.energy/api/v1/tracker/G-1R-SILVER-2017-1-{grid_code}/monthly/future/{num_months}/{consumption}/
2020-04-01 23:24:13.159965 WARNING octocost: ------------------------------------------------------------
2020-04-01 23:24:13.183449 WARNING octocost: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 766, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/octocost/octocost.py", line 29, in cost_and_usage_callback
self.yesterday = datetime.date(today.year, today.month, today.day-1)
ValueError: day is out of range for month
2020-04-01 23:24:13.191171 WARNING octocost: ------------------------------------------------------------
Should use time delta for date maths.
No checks are done when multiplying usage by cost, they are just processed as a list so missing usage data can cause the usage to be multiplied by the wrong cost.
Unmatched consumption 2020-03-29T02:00:00+01:00 / cost 2020-03-29T01:00:00Z
Unmatched consumption 2020-03-29T02:30:00+01:00 / cost 2020-03-29T01:30:00Z
Unmatched consumption 2020-03-29T03:00:00+01:00 / cost 2020-03-29T02:00:00Z
Consumption data from Octopus Energy is DST aware, while price data sticks with Zulu time (UTC), so need to compensate for this.
Hi, sorry to post this here.. Is octocost still on HACS as I'm on the latest HACS 1.8.0 and octocost is not showing up in search. Also I'm not on the agile tarrif, will this still work for my normal tarrif? I have API code and region letter and serial etc..
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.