Comments (6)
Ah I see the issue. I think you're on an tarrif with no current end date, whereas I'm assuming there's always one. I'll rectify this hopefully tonight.
from homeassistant-octopusenergy.
Think i've cracked the empty response to curl -u "sk_live_muhkey:" "https://api.octopus.energy/v1/accounts/A-MUHACC"
as curl -u "sk_live_muhkey:" "https://api.octopus.energy/v1/accounts/A-MUHACC/"
brings back everything I expect (note the closing slash). I expect curl does not follow the redirect but the python library does.
I think this would still hit the issue you've described as the 'valid_to' field is null in my response.
from homeassistant-octopusenergy.
from homeassistant.util.dt import (utcnow, as_utc, parse_datetime)
import datetime as dt
def get_active_agreement(agreements):
now = utcnow()
for agreement in agreements:
valid_from = as_utc(parse_datetime(agreement["valid_from"]))
if agreement["valid_to"] is not None:
valid_to = as_utc(parse_datetime(agreement["valid_to"]))
else:
valid_to = now + dt.timedelta(seconds=1)
if valid_from <= now and valid_to >= now:
return agreement
return None
Python is not my thing but this appears to work.
from homeassistant-octopusenergy.
Yup that's the area. I've updated to handle it slightly differently to how you did it, just because I don't want to make any assumptions. Closing issue as I've applied a fix, but feel free to reopen if my fix is somehow still broken
from homeassistant-octopusenergy.
Ah, that's the path I took originally but I think won't work. The valid_to field will always exist, but the value may either be None or a string. I think (unless my knowledge of Python is way off) the altered code will have the same issue as reported.
from homeassistant-octopusenergy.
I think it should be fine, but to be on the safe side I've added the additional check you had as well.
from homeassistant-octopusenergy.
Related Issues (20)
- Home Assistant core backup HOT 1
- Entities disappeared since updating to 11.1 HOT 4
- Add "Minimum time left" to Rolling Target sensor HOT 1
- Home mini electricity data no longer updating every minute HOT 53
- sensor.octopus_energy_electricity_ ... _current_demand is returning "0 1" instead of a valid number HOT 3
- Error setting up entry A-######## for octopus_energy HOT 3
- Error setting up entry A-<account ID> for octopus_energy - "KeyError: 'account_id'" HOT 6
- Octopus Home Mini readings only updating every 30 minutes HOT 3
- Can't select correct electric meter for tariff comparison. HOT 12
- Unable to query smart meter telemetry data HOT 2
- The value of the HTTP Authorization header is not recognized as a valid access credential for this API HOT 3
- Send the current applicable rate for the interval with the octopus_energy_electricity_current_day_rates event HOT 1
- setting target rates before 4pm and after middnight not working, even when data available HOT 6
- Cost tracer log errors HOT 2
- OpenAI Conversation HOT 3
- Current Accumulative Cost Electricity not updating since June 16th HOT 12
- Tariff Comparison returns data based on previous consumption offset HOT 3
- Gas sensors not working HOT 4
- Wrong naming in the entities HOT 3
- Current Accumulative Consumption & Cost Not Working with Home Pro HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homeassistant-octopusenergy.