Comments (10)
I am not aware of any secure caching functionality right now in HomeAssistant. Although I guess the Wiener Netze API offers to renew a particular token by using the refresh token along side the access token, we cannot really persist them in HA I fear.
from wienernetzesmartmeter.
Okay, but also username and password is stored? Can we not just use the same approach?
from wienernetzesmartmeter.
from wienernetzesmartmeter.
Maybe it is a good idea to switch to a proper OpenID-Connect library, which can handle all these things.
I also checked the token response, they are valid for 300 seconds, and the refresh token for 1800s (30min).
Thus, with the change to request only every 60minutes, we would have to login any ways or have another job running in the background that does the refreshing.
I guess the website sets a cookie with a longer lifespan?
from wienernetzesmartmeter.
regarding OpenID: that would be for sure the more stable solution, though we are assuming that log.wien correctly implemented it according to the standard.
We may have to reverse engineer that part, but imho it's worth a try.
regarding the token: Home assistant does not provide afaik the possibility to launch separate scheduled tasks then the update lifecycle. What we could do is reduce the update cycle to happen < 30min and first use refresh token and if that fails as a fallback the credentials login and update the sensors merely every 2nd-3rd time.
If the refresh token endpoint is computationally more efficient (as it should not require a persistence lookup) we could save them some load and give back some performance.
What do you think @reox?
from wienernetzesmartmeter.
regarding OpenID: that would be for sure the more stable solution, though we are assuming that log.wien correctly implemented it according to the standard.
The question is also if we are acting according to any standard :D
What we could do is reduce the update cycle to happen < 30min and first use refresh token and if that fails as a fallback the credentials login and update the sensors merely every 2nd-3rd time.
Or even reduce it to 5min and just update the API every half an hour. I implemented something similar with the statistics, to only query after 24h after the last imported stat, eve if the update function is called more often.
from wienernetzesmartmeter.
regarding OpenID: that would be for sure the more stable solution, though we are assuming that log.wien correctly implemented it according to the standard.
The question is also if we are acting according to any standard :D
For sure not. But as of my experience openId is often not implemented according to the standard. Just to keep that in mind, when integrating into an external system.
What we could do is reduce the update cycle to happen < 30min and first use refresh token and if that fails as a fallback the credentials login and update the sensors merely every 2nd-3rd time.
Or even reduce it to 5min and just update the API every half an hour. I implemented something similar with the statistics, to only query after 24h after the last imported stat, eve if the update function is called more often.
calling every 5 minutes is a bit too much. Most frequently 15 minutes is I guess already enough.
Regarding your grace timeout logic: I agree, we could probably think of update ifnext day after updatets at 00:00 < now
from wienernetzesmartmeter.
I had a look on what is taking so long during login. It is actually the fetching of the API keys from the javascript files.
The file that has to be downloaded is 1.8MB (okay, it is gziped to 400kB..)
Maybe a good addition would be to cache these keys. For starters, one could take the proposed cache value from the http response.
from wienernetzesmartmeter.
there you have a point.
You've got a good idea there:
We could download and cache the keys (by downloading the html-file -> js-files -> api keys) if
- the cached key is
None
or - the login with the cached key fails due to a wrong key, as a fallback
and use the cached one as long as it doesn't fail to login due to invalid keys
What do you think @reox ?
from wienernetzesmartmeter.
I thought about that too. Probably would have to check in the _call_api
function then if the call fails and if so, request new keys.
from wienernetzesmartmeter.
Related Issues (20)
- No hourly data downloaded when the account includes an inactive zaehlpunkt ("Returned data does not match given zaehlpunkt!") HOT 40
- TypeError "Can't override _attr_state_class in subclass" in 1.4.2 HOT 11
- v1.4.2: The following integrations and platforms could not be set up: wnsm.sensor HOT 1
- no data showing up after (version 1.43) KeyError: "Sum" in Logfile HOT 3
- Einspeisezählpunkt wird gefunden aber keine Daten HOT 1
- after update 1.4.3 statistic entity is not working HOT 2
- Error on device update HOT 2
- since middle of January statistic entities are not working HOT 7
- trigger reimport of data due to huge negative consumption error? HOT 10
- Statistics Import Stops Working after Renaming Statistics Entity HOT 2
- Energy Dashboard shows feeding without actually feeding in place HOT 31
- Problem with 29.02. HOT 2
- Subsequent update to statistics after initial import is not working HOT 5
- wnsm: Error on device update HOT 7
- No statistics are imported the day after the consumtion HOT 1
- Subsequent update to statistics after initial import is still not working HOT 12
- Multiple contracts causes issue with live sensor HOT 19
- two Smartmeters under the same contract. consumption and production HOT 3
- HomeAssistantType was used from wnsm, this is a deprecated alias which will be removed in HA Core 2025.5 HOT 2
- Keine Verbindung seit neuem Einspeisepunkt HOT 16
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 wienernetzesmartmeter.