Toon (eneco) integration with Home Assistant

@krocat I made the MR. Now I can graph my current gas usage too, on my grafana :slight_smile: . Really happy :slight_smile: Now lets get those smartplugs working ā€¦

Will test it tonight :wink: many thnx for your work

1 Like

Thanks for the review. Iā€™ve tested your changes and commited them to the main branch

Hey @costas, Iā€™ve created a new branch for integrating the smart plugs (Smart-Plugs-integration). In there, Iā€™ve created a switch module and set-up a framework based on some of the examples. Iā€™ve not yet figured out how to best check for the existence of any plugs or how to update, as for the climate device and the sensors I didnā€™t have to enumerate. Any advice on that is appreciated.

Hi @krocat. I am not really sure that I am clear on what you mean. If i understand what you are asking, you validate the existence of smartplugs if there are any in the toon.smartplugs attribute. If there are none you should have an empty list. Now as for the updating part, accessing any attribute on any smartplug will trigger a retrieval of the appropriate information of the parent toon object internally getting the info from the cache if it is not invalidated (within the 5 minute period) or updating the cache if not. So basically just accessing any attribute would be enough. Tomorrow I will have a look at your code and try to fit it with my plugs and give you feedback on that. If I have not understood your questions and my answers were not appropriate please elaborate and I will get back to you.

I am thinking that we could probably lower the caching down to a minute of something since the library keeps the connection open and does not reauthenticate all the time. That being said I am trying to see when we get kicked out of our session. In a testing run I have it is after two days of something. So i have added debugging around that and I will try to catch the invalidation of our session and automatically refresh it so we can have a long lived process that transparently refreshes the authentication when invalidated.

Hi @krocat would you like to make me contributor to the ToonHA? It would simplify stuff not having to fork to do an MR.

@costas, sorry for the incoherent post yesterday, I was tired and should have gone to bed instead :slight_smile: I struggled with how best to enumerate the switches and update them without creating multiple instances of your library. Things look much clearer in the morning and I committed some additional code on the smartplug branch. I havenā€™t tested it out yet, but I thought Iā€™d let you have a look. You are a contributor on ToonHA now. Let me know what you think.

@krokat, no problem, I guess if I was not too tired too, I would have understood you better, but I was struggling too :slight_smile: I will have a look soon, thanks for accepting me as a contributor.

@krocat, I have just pushed a working version of plugs on your branch. I also added sensors for the consumption as it seems that Home Assistant does not push the values to influxdb from the switch although they show up. With the sensors setup i get values just fine so I can have my graphs and be happy :slight_smile: . Please review and let me know what you thinkā€¦ Now I have to implement the turning on and off of the switches even though I have them on a locked state because I really donā€™t like the switch not workingā€¦ :slight_smile: Thanks for all your amazing work on this it was a lifesaver!!

Thanks @costas! So cool we got this working. Itā€™s amazing how quickly you can develop stuff when you work together like this. And the best thing is, you make my code look pretty. I almost feel like a real developer ;-). Could you perhaps share a screenshot of the new sensors and switches that you get when you have a smartplug connected? The only thing I can validate is that it doesnā€™t break if you donā€™t have one. I looked online, but even second hand these things go for 40+ Euro.

Do you think weā€™re ready to submit it to HA as an official component? @opdoffer, did you test as well? Is everything working? Do you have smartplugs? Or anyone else following this thread. Please test in your environment and let us know if you have any issues.

@krocat yeah its really fun! I want to implement the turning on and off of the plugs before. We could also do with an icon for the climate :slight_smile: I will try to implement the on and off in the evening so I should have a working version by tonight. I will add some screenshots in a while. @all feedback is welcome!

That is so cool! Thanks for that. I will wait for you to implement on/off for the switches and then commit everything into the main branch. In the meantime, Iā€™ll read up on what we need to do to get this into HA.

Also, if thereā€™s someone with solar panels connected to Toon, it might be interesting to add sensors for that. Again, I canā€™t test because I donā€™t have any.

What exactly do you want tested?
I can at least test the Toon integrationā€¦which Iā€™ll do right now :slight_smile:

Ok so I created the custom_components folder (it didnā€™t exist) and created the subfolders climate, sensor and switch etc.
but how do I install the toonlib?
I tried pip install toonlib, but it says ā€œ-bash: pip: command not foundā€.
Can you tell me how I can install it?
I run hassbian.

Hi @PuckStar, it would be great if you could test that the Toon component loads correctly, you can change the state, change the temperature manually etc. If you have an Eneco smart plug, could you also test this version (smart-plug-integration branch):

Thanks!

@PuckStar You donā€™t have to install the toonlib, it is installed automatically as a dependency by HA

Hi fine gentlemen. Actually i just pushed a new commit that bumped the dependency to version 0.2.0 of toonlib that can turn on and off plugs. (and lights but that is not or concern here, just mentioning. ) Get it while its hot! feedback is welcome.

@PuckStar so please use the latest since you are going through the trouble :wink:

@krocat switching is implemented and tested by me, works like a charm so if you test it too and we hear back from @PuckStar you can merge to main. As soon as i figure out the automatic reauthentication we can try to push this to mainline of HA. This was a very fine job, thanks for everything! I can soon dump openhab and use HA :slight_smile:

Hi all i tested your yesterday version and HA crashed after running 18 hours. I will dig into this and first deploy your latest version and let it run for a day.