Toon van Eneco custom component

If we are bothered by these messages I could implement a timeout on the retrieval shorter than 10 secs so the network call would fail before Home assistant nags and we would get served the stale value from the state. Lets see how ofter these messages come up and if it’s worth dealing with.

Ah, I get it. They don’t bother me per se and I don’t see them very frequent (2 or 3 times a day). I would say, let’s leave them for now and see what the reactions are when people start using the component.

Is this something that should be a debug message? As far as I can see, Toon is still updating after this:

2017-05-08 15:36:36 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.power_today fails
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    None, self.update)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/sensor/toon.py", line 95, in update
    self.thermos.update()
  File "/home/homeassistant/.homeassistant/custom_components/toon.py", line 87, in update
    self.data['power_current'] = self.toon.power.value
  File "/home/homeassistant/.homeassistant/deps/toonlib/toonlib.py", line 281, in power
    power = self._state['powerUsage']
  File "/home/homeassistant/.homeassistant/deps/cachetools/__init__.py", line 46, in wrapper
    v = func(*args, **kwargs)
  File "/home/homeassistant/.homeassistant/deps/toonlib/toonlib.py", line 175, in _state
    state.update(self._get_data('/client/auth/retrieveToonState'))
  File "/home/homeassistant/.homeassistant/deps/toonlib/toonlib.py", line 189, in _get_data
    response = self._session.get(url, params=params or self._parameters)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/sessions.py", line 501, in get
    return self.request('GET', url, **kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/sessions.py", line 641, in send
    r.content
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/models.py", line 797, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/models.py", line 719, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/srv/homeassistant/lib/python3.4/site-packages/requests/packages/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/lib/python3.4/http/client.py", line 500, in read
    return super(HTTPResponse, self).read(amt)
  File "/usr/lib/python3.4/http/client.py", line 539, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:1769)

Hi @krocat, this exception is not from our code. It is an ssl issue (which is strange because I would expect this to appear much more consistently since it seems to be due to an openssl issue).

I have three such errors over the last twelve hours. They are very verbose. Even though it’s not in our code, can we catch it and suppress the lengthy log errors?

No, i am afraid not, because they happen outside the scope of our code. Home assistant uses futures to update its values, so a lot of things are happening concurrently. Errors like these (not this one specifically, because this is an ssl error but others like these) come from the fact that multiple threads try to access the same resource while the resource is changing so at some point in time there will be a race condition with something accessing something that just changed. Sadly, not much we can do about it.

Fair enough. Just had another one. Today seems to be a bad day for SSL. For the rest everything is still running smoothly. I think we should prepare for our submission.

great! go right ahead!

Boom!

https://github.com/home-assistant/home-assistant/pull/7527

Sweet! Well done!

And… thats how its done! Great, congratulations! Now, should we also make a component for ovchipcard and uitcheckgemist ? The libraries are already there :wink:

Actually, I was talking to @opdoffer about doing an Albert Heijn Appie component. Think about it, you could put a pressure sensor underneath your beer stash and have HA put beer on your list when you’re running out. I’ve been experimenting with an API by svdgraaf:

https://github.com/svdgraaf/appie/issues/4

However, the functionality to add stuff is broken and I haven’t been able to figure out a fix. Ah may have changed something in their authentication. The API accepts my input, but it’s not added to my personal list. Since you are the API-master @costas, could you have a look?

Sure, I will have a look, sounds fun! Care to give me an initial push? What is this appie thing? I have not used HA accounts for anything. Any documentation I could start with?

I’ll DM you so as not to clog this Toon thread with other stuff

1 Like

Hi @krocat,

I was wondering if there are any updates on the Toon component.

I’m currently setting up a fresh home assistant setup and i was wondering if i should wait until
https://github.com/home-assistant/home-assistant/pull/7527 is done/accepted or that i should use the current code as is.

Hi smikje, We should be close, but there is still one outstanding item that I don’t understand. It looks like they want me to implement states like heat, cool, away, instead of Toon’s programs (Comfort, Home, Away, Sleep). I haven’t received a comment on my last question for a while. I’ll send them another note.

Hey @krocat ! I was just about to ask what is the current state of affairs with toon and I saw your message on github. I am guessing that there is some sort of lost in translation situation. I have added a comment on the MR. I hope things go forward soon. By the way how are you? :slight_smile:

Now that Eneco is raising the monthly costs to use Toon externally I’m very interested in knowing if anyone could get the Toon component working with Hass without needing the Eneco Toon subscription.
I only have this subscription of 4,50 euro’s per month to be able to interact with Toon externally. So if in any way we can get it working without that subscription I can save 54,- euro per year.

1 Like

Is it possible to read the temperature sensor an use it as a sensor.
I’m quite new to HassIO but getting close by the day.

I saw this but I can’t get it working

image

2 Likes

You could use a sensor template for that.