That is right, that is how you get the current value of power. I notice that I miss that in the documentation, fixing it right now! Thanks!
Documentation fixed. Thanks! Please donât expose any of the graph or flow data yet until I implement some caching on them ok?
@costas when I set a temperature or state, do you update the cached data? When I use my component with your api and I change the state, it immediately reverts back to what it was until the 5 minutes are past and it shows the correct state.
Hi,
when you set the temperature or a thermostat state the cache gets cleared right away so querying the value again should give you the correct result. Do not cache on the component level as the caching is done internally in the library.
I did more testing and you are correct when it comes to switching states. However, when Iâm set to Home and I manually change the temperature to 20,5 degrees, it takes the api a full 5 minutes to realize no program is active.
Thereâs a new version of the custom component on Github that uses the toonlib library. For now, itâs just the functionality I had connecting to rvdmâs Toon API, but from here on we can expand it to include things like smartplugs. A couple of development areas:
- Sometimes the toonlib returns an incomplete json response and the climate device wonât initialize
- When switching from a state to manual temperature, the display wonât update until the next 5-minute sync
- Switching states is not as fluently as Iâd like.
Comments are welcome!
The api response for updating the state is extremely flaky and inconsistent. What I do on the lib is query the api three times and actually update the cached state with the response in the hope that all needed information is retrieved, If it is not then the cached answer is in place so there shouldnât be any incomplete answer, just not absolutely fresh ones. Sadly not much we can do there, its how the api responds.
I will have a look at the state transitioning. You mention that the api does not update until 5 minutes after. You mean the actual api and you checked by refreshing after you have set a thermostat state or do you mean the library so i missed something with the cache invalidation on the thermostat states?
I checked the code and the changing of the state invalidates the cache. So it seems that it is the api that does not update its response. Sadly, not much we can do about that if we want to handle the api response as the source of truth (as we should.)
Just set up your component, works great! Thanks! Any guidance on how to set up smartplugs?
Hey @costas, I donât own any Eneco smartplugs myself. I think they are similar to wemo plugs for which there is already a HA component. Looking at that, I see properties for power consumption as well as on/off, so it shouldnât be hard to port that to your api. I may have a go at it later today, but again, I canât test it with actual plugs.
Thanks for all your trouble! If you donât have the items I think its just going to be annoying, I will read over the code of the wemo plugs and try to port it to your codebase so we can keep things in one place. Once everything is done we should probably try to push your component to the mainline right? Not sure when I will have the time to look into this but I guess during the week sometime.
Indeed. Although I would want to dig into the state switching issue before we submit. When I use the component to switch to manual temperature, my Toon iPhone app picks that up immediately. There must be something weâre missing.
They are probably using websockets for the app updating but the api has its own internal cycle. Could I make some comments on the sensor you are exposing for gas and power? I think that the naming is a bit lacking especially for the daily consumption. Wouldnât it be better to name the sensors sensor.gas_current sensor.power_current and the dailies sensor.gas_today and sensor.power_today? Also there is no sensor for gas today only power?
If you agree with the comments I could change them and make an MR for you so you donât do everything yourself. I will look into the updating of the state but probably not before wednesday, is that ok?
Well, turns out it was a bug with my code. Thats what you get without a test harness. I did some refactoring and some stuff was left with the old way of working that was breaking on the logging, thus, not clearing the state. Pushing a new version now, problem should be solved and state should update real time. sorryâŚ
Brilliant, it works Agree on the naming, if you could create a MR that would be great. the Gas gauge shows the daily usage, Iâm not sure if it makes sense to show current usage for Gas? Iâm mirroring the Toon app, which has daily usage for Gas and Power and then current usage for Power as well.
The updated component is on Github. @costas, do we need the warning when the state is set to manual? This could really clog up the log:
17-04-24 11:01:50 WARNING (Thread-11) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
17-04-24 11:01:50 WARNING (Thread-8) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
17-04-24 11:01:55 WARNING (Thread-4) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
17-04-24 11:01:55 WARNING (Thread-7) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
17-04-24 11:01:55 WARNING (Thread-10) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
17-04-24 11:02:07 WARNING (Thread-9) [toonlib.Toon] Manually set temperature, no Thermostat State chosen!
I will make that MR at some point during the day. I think that when we have data we should use it so showing the current gas usage makes sense to me. I think we should expose everything we can and everyone can choose whether they want/need something showing up or not.