Code Monkey home page Code Monkey logo

octocost's People

Contributors

badguy99 avatar shadow-fight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

octocost's Issues

change call back to run at a defined time rather than offset from local time

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.

Get tarrifs and start dates from api if account id given, and if using tracker get data elsewhere

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}/

Date maths blows up

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.

Data Doesn't Match the octopus Website

The data pulling through doesn't match the data shown in the octopus my account usage.

image

image

as a result the costs are also off, is it to do with timezones or DST?

Deal with daylight savings in consumption date but not price date

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.

Octocost in HACS

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.