Toon van Eneco custom component

Hey guys, I’ve created a custom component to interact with my Toon thermostat from Eneco. It’s kind of similar to integration that opdoffer created, but the component allows for an easier set-up and I like having a real climate device better over scenes and switches.

The files are here: https://github.com/krocat/ToonHA

Let me know what you think

4 Likes

Don’t know if you guys want more errors but this is what I just saw in the log:

17-05-01 22:03:03 ERROR (Thread-10) [toonlib.Toon] 
	Status Code :500
	Text :{ "success": false, "reason": "Cannot retrieve common name for client: 7dd9b04a-60a2-4c20-91ca-80509bad082d", "errorCode": "500" }
17-05-01 22:03:03 ERROR (Thread-10) [toonlib.Toon] Could not get answer from service.
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/toonlib/toonlib.py", line 167, in _state
    state.update(self._get_data('/client/auth/retrieveToonState'))
TypeError: 'NoneType' object is not iterable
17-05-01 22:09:05 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on SSL transport
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 825, in _read_ready
    data = self._sock.recv(self.max_size)
  File "/usr/lib/python3.4/ssl.py", line 730, in recv
    return self.read(buflen)
  File "/usr/lib/python3.4/ssl.py", line 619, in read
    v = self._sslobj.read(len or 1024)
OSError: [Errno 113] No route to host

That is the api not responding. I am currently testing code that changes the way we query the api and so far it looks much better and with a much better refresh rate. Hold on to your hats… At some point you should get an error like this but for a deauthentication and then I would guess you will not get any updated values any more with continuous errors and you will have to restart. That message, i am very interested in… Let’s see who gets there first :slight_smile:

Here’s something new:

17-05-02 06:56:25 ERROR (Thread-3) [toonlib.Toon] 
	Status Code :502
	Text :<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>awselb/2.0</center>
</body>
</html>

However, I’m still updating, so it seems. I get a lot of these:

17-05-02 09:20:31 ERROR (Thread-8) [toonlib.Toon] 
	Status Code :500
	Text :{ "success": false, "reason": "Cannot retrieve common name for client: 88e23b32-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "errorCode": "500" }

And then some of these:

17-05-02 09:20:31 ERROR (Thread-8) [toonlib.Toon] Could not get answer from service.
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/toonlib/toonlib.py", line 168, in _state
    state.update(self._get_data('/client/auth/retrieveToonState'))
TypeError: 'NoneType' object is not iterable

I am guessing this is a load balancing issue on their part. As to the other ones the code I am currently testing is running for an hour and a half with no messages so far. I will keep you updated.

The api is having a good day though, my last error is from 11:58:05

i am only getting warnings for slow responses, no errors so far.

17-05-02 13:20:31 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.dryer is taking over 10 seconds. 
17-05-02 13:22:34 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_current is taking over 10 seconds. 
17-05-02 13:24:38 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_current is taking over 10 seconds. 
17-05-02 13:27:44 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.dryer is taking over 10 seconds. 
17-05-02 13:33:56 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_current is taking over 10 seconds. 
17-05-02 13:41:10 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_current is taking over 10 seconds. 
17-05-02 14:20:56 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_current is taking over 10 seconds. 
17-05-02 14:20:56 WARNING (MainThread) [homeassistant.helpers.entity] Update of switch.dryer is taking over 10 seconds.

This is the whole log of the testing code…

oh, by the way I am caching just for 30 seconds

I have just one of those for the entire day:
17-05-02 13:04:19 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.power_today is taking over 10 seconds.

30 seconds! Now we’re talking. This will be better than the real api once we’re finished :slight_smile:

:slight_smile: I am very confident for the resiliency of the code so far. I am waiting to hit the deauthentication so I can tackle that too and then off to the mainline :slight_smile: How are you doing with reading up on the process @krocat? Do you need any help with anything? By the way if the library responds well do you mind having another talk about the initialization of the component? :blush:

Hi @costas, always happy to discuss that. I just don’t want a component that you have to restart three times before it works :slight_smile: I’ve created a new housekeeping branch with some of the stuff out of your cookiecutter repo. ToonHA now also has a version number. By looking back at what we’ve done, I figure we’re at 0.5. I also included a Tox.ini but that doesn’t get me any further as I would need a setup.py of some sorts, which might be difficult in an HA component. Can you perhaps take a look at the testing part, they seem pretty strict with what they accept and do not accept in terms of coding. In the meanwhile, I’m working on getting the documentation for the home-assistant.io site ready.

@krocat there is no way that this does not work excellent when we are done with it, or i am not going to be done with it, don’t worry! I am happy to take a look tomorrow at that branch :slight_smile:

1 Like

What do you think?
https://github.com/krocat/home-assistant.github.io/blob/next/source/_components/climate.toon.markdown

Can’t really judge, looks fine to me :slight_smile: Did you miss the ‘my.tado.com’ in the documentation?

Ah, thanks. That’s why it’s always good to have someone review :wink: Any luck with the testing?

Still going fine. No problems except some delay messages. No de-authentication yet so not much to do…

No, I mean the Tox stuff. I think we need to do these final reviews and then switch to your lastest toonlib and we should be ready to submit

I replied to the email notification and apparently it does not integrate. Sorry, have not looked much into it. I am a bit busy the next few days so won’t have much time.
However on https://home-assistant.io/developers/development_checklist/ it mentions :

The .coveragerc file is updated to exclude your platform if there are no tests available or your new code uses a third-party library for communication with the device, service, or sensor

which is the case with this component. There is no testing because it uses a third party library, toonlib so I guess we are fine with just the appropriate documentation.

Ok, cool. When you’re happy with the library we’ll just submit and see what happens