home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.46k stars 29.39k forks source link

[Climate] Toon doesn't setup on version 0.87.1 #21010

Closed maartenpaauw closed 5 years ago

maartenpaauw commented 5 years ago

Home Assistant release with the issue: 0.87.1

Last working Home Assistant release (if known): 0.87.0

Operating environment (Hass.io/Docker/Windows/etc.): Docker

Component/platform: https://www.home-assistant.io/components/climate.toon/

Description of problem: Component doesn't work after update.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

toon:
  username: !secret toon_username
  password: !secret toon_password

Traceback (if applicable):

Error during setup of component toon
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/toon.py", line 52, in setup
    hass.data[TOON_HANDLE] = ToonDataStore(username, password, gas, solar)
  File "/usr/src/app/homeassistant/components/toon.py", line 70, in __init__
    toon = Toon(username, password)
  File "/usr/local/lib/python3.6/site-packages/toonlib/toonlib.py", line 66, in __init__
    self._login()
  File "/usr/local/lib/python3.6/site-packages/toonlib/toonlib.py", line 123, in _login
    self._authenticate()
  File "/usr/local/lib/python3.6/site-packages/toonlib/toonlib.py", line 81, in _authenticate
    data = response.json()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Additional information:

screen shot 2019-02-12 at 16 12 29

MajorGlory78 commented 5 years ago

Just noticed the same error. After initial update it seemed to be working. After restart of Hassio just now I get the same setup error. Will try to restart Toon first and it could be a problem with the Toon API as well....

Restart of Toon and/or restart of Hassio doesn't work.

timon71 commented 5 years ago

Same issue here after updating to 0.87.1 on HassOs 2.8.

hendr00 commented 5 years ago

Same issue using docker container 0.87.1

Knol010 commented 5 years ago

Same issue here after updating hassio. After downgrading to 0.87.0 it is not working anymore.

aalbul commented 5 years ago

the same issue here

daniel360gt commented 5 years ago

I think the problem is with Toon itself. I'm running HASSIO 0.84.2, same issue.

timon71 commented 5 years ago

Probably because Eneco stopped supporting the services for iPad en old mobile apps since yesterday? See https://forum.eneco.nl/storingen-en-oplossingen-112/inloggen-toon-op-tablet-werkt-niet-20978

The mobile app on my iPhone still works. So my guess is that the login URL or procedure has changed?

aalbul commented 5 years ago

Are there any plans to migrate to https://github.com/costastf/toonapilib ? seems like it is using official toon API and is a logical continuation of https://github.com/costastf/toonlib as it was deprecated.

hmmbob commented 5 years ago

Probably because Eneco stopped supporting the services for iPad en old mobile apps since yesterday? See https://forum.eneco.nl/storingen-en-oplossingen-112/inloggen-toon-op-tablet-werkt-niet-20978

The mobile app on my iPhone still works. So my guess is that the login URL or procedure has changed?

In that topic and other topics related to it, it is discussed that Eneco took down an older backend service (which apparently was used by the Toon Climate component for HA) and that service for this older backend will not be restored. Eneco points out that services wanting to use this information, need to use the new API (docs at https://developer.toon.eu/toonapi/apis).

That would mean that....

Are there any plans to migrate to https://github.com/costastf/toonapilib ? seems like it is using official toon API and is a logical continuation of https://github.com/costastf/toonlib as it was deprecated.

.... would likely fix this issue. I am definitely not a coder, but happen to read some Dutch at the Eneco forums....

frenck commented 5 years ago

I've started working on a replacement implementation. Let's see if I can manage to get something out.

scheric commented 5 years ago

@frenck There is already an updated version for this component at https://github.com/costastf/toonapilib It uses the new official API. Only one issue has to be resolved: krocat/ToonHA#40. After that it can be migrated directly.

Knol010 commented 5 years ago

So it will be solved in the new update from HA?

frenck commented 5 years ago

@scheric Yeah I have based it on that. I'm also doing generic upgrades (async) and add in all the new bells and whistles (configuration from the UI).

Got a POC working yesterday, will continue on working on it and try to see if I can make it in time for the 0.90 release.

@Knol010 No, Home Assistant 0.89 has been frozen already (already in beta).

hmmbob commented 5 years ago

@frenck Do you think it would be possible to let the build-in component support Rooted Toons as well, in the same package? Those don't use the Eneco API, but a local API in the Thermostat itself.

frenck commented 5 years ago

@hmmbob No that is not possible, that logic would differ completely and should really be implemented as a separate component.

frenck commented 5 years ago

@scheric I read your comment again and was incorrect in my response (or can be confusing). I'm using the toonapilib by costastf, but am not basing it off the krocat component version.

While I use the krocat version myself as well (at this moment), it is not up to par with the latest and greatest best practices of HA. Hence I've started on an implementation from scratch. Implementing, async, config entries, data entry flows (Integrations from UI), entity registry, device registry, supports areas, also added in support for multiple devices (in the same or different accounts).

Current state: Finished with basic component setup. Configuration from UI works (includes authentication from the UI), Toon display selections and the Toon devices get registered and are showing up nicely including firmware information and such.

Next steps would be setting up the specific platforms (climate, binary_sensors, sensors, switches, and lights).

timon71 commented 5 years ago

@frenck Will there also be a binary sensor for “burner status” as well? There wasn’t one in the offical component. I use a custom component for “toon” where i could use this sensor as a trigger. If it is usefull i will add the toon.py as attachment.

frenck commented 5 years ago

@timon71 Thanks, but not needed. Got the data... Working on the representation. Burner status will be in there... but not sure if that would be a binary sensor or an attribute of the climate component.

In case of it being an attribute, you can always use a simple template to turn it into a binary sensor (no hacking needed).

jpduhen commented 5 years ago

Can't wait ;-)

frenck commented 5 years ago

Current state: 2019-02-16 18 49 47

Starting with sensors now.

hmmbob commented 5 years ago

That's pretty cool. Now I feel even more jealous for not having the official integration.....

timon71 commented 5 years ago

Nice job Frenck. Hardly can't wait for the release. Keep up the good work.

frenck commented 5 years ago

Got most stuff up and running. Still needs work in quite a few departments, but it is running smoothly.

I'm thinking about not implementing Light support. Since the Toon only supports Philips Hue and well, that is natively supported by Home Assistant. IMHO it makes not much sense to support it on this component.

The Switches & Smoke sensors are kinda the same story...?

What do you guys think about Light, switches and smoke sensors?

aalbul commented 5 years ago

I think that for the first flice they are definitely not needed :)

hmmbob commented 5 years ago

I agree. I'd only expect the Toon Climate control and specific Toon sensors ("metersensors") to be present in the component.

Switches etc are better done directly integrated in HA.

frenck commented 5 years ago

Ok, current state in that case:

image

image

Some sensor values still need some calculations/adjustments,

Knol010 commented 5 years ago

Great work

timon71 commented 5 years ago

That’s much more then there ever was. Looking great.

frenck commented 5 years ago

image

image

image

image

image

Binary sensors are there as well now, added checks for features (e.g., in case you don't have solar, it should not create the sensors).

I do have some issues with some sensors. Further investigation showed the Toon API simply doesn't return values for the following:

In contrast of missing Power & Solar cost information, the API does return the costs for Gas perfectly, so that makes no sense(or). So for now I leave those 2 out. I currently doubt if I should leave gas costs in or not.... What do you think?

jpduhen commented 5 years ago

Gas-costs, why not implement if it’s there and functioning all-right? I vote to include (not considering the amount of work on your side ;-).

Burner-status is also very useful in my house: my floor-heating has a separate pump, but it is always on. Based on the burner-status I can switch it on and off, depending if the heater is really working or not (with a little hysteresis).

That’s certainly very strange solar energy behavior on the Toon-side you discovered. I do have solar panels but I switched to an other power-company before I got them installed, so I have no Toon-solar extension. I’m planning to use one of these: https://nl.banggood.com/AC-Digital-Multifunction-Meter-For-Arduino-p-1232733.html?cur_warehouse=CN connected to an ESP-01 or WEMOS te get the solar-data into HA.

Can’t wait to give the new Toon-component a try...

aalbul commented 5 years ago

@frenck thanks for such a valuable work! Regarding electricity / gas costs. If API always returns 0, can't we just hack it a bit and request gas/electricity graph like this:

img_0559

and then take only the head of the graph?

frenck commented 5 years ago

@aalbul I don't have access to that data from the current state of the library used. We could look into adding that in a future release. For now, my focus was on getting the component in a working and clean state.

hmmbob commented 5 years ago

@frenck looks great. I know what you've said before, but do you think this would be easy to port to a version that supports the rooted Toon?

I can imagine one doesn't need the onboarding flow with Eneco as the API is local, but do you think other parts of your code are portable?

frenck commented 5 years ago

@hmmbob I don't own a rooted Toon, therefore I'm not the right person to ask or write this.

cyberjunky commented 5 years ago

It's something I look into, but some info is not available on the rooted toon. Frenck, is your code available somewhere?

On Mon, Feb 18, 2019 at 10:35 PM Franck Nijhof notifications@github.com wrote:

@hmmbob https://github.com/hmmbob I don't own a rooted Toon, therefore I'm not the right person to ask or write this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/21010#issuecomment-464888157, or mute the thread https://github.com/notifications/unsubscribe-auth/AFMd-fwZCC5TvD03w_sEv1jpDj6VtLO8ks5vOxyegaJpZM4a2oRb .

cyberjunky commented 5 years ago

Nevermind, just saw the PR. ;-)

On Tue, Feb 19, 2019 at 8:48 AM Ron ron@cyberjunky.nl wrote:

It's something I look into, but some info is not available on the rooted toon. Frenck, is your code available somewhere?

On Mon, Feb 18, 2019 at 10:35 PM Franck Nijhof notifications@github.com wrote:

@hmmbob https://github.com/hmmbob I don't own a rooted Toon, therefore I'm not the right person to ask or write this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/21010#issuecomment-464888157, or mute the thread https://github.com/notifications/unsubscribe-auth/AFMd-fwZCC5TvD03w_sEv1jpDj6VtLO8ks5vOxyegaJpZM4a2oRb .

hmmbob commented 5 years ago

It's something I look into, but some info is not available on the rooted toon.

Let me know when you need testers 👍

scheric commented 5 years ago

@frenck

* **Power costs today**: Always `0.0` returned by the API.

* **Solar costs produced today**: Always `0.0` returned by the API.

* **Solar Produced**: Contains the value of what is actually flowing back to the feed OUT. Weird.

* No data insights on how much kWh of solar was actually produced today.

Do you have an power and gas subscription from Eneco?

take a look at this Eneco forum static web link for image

frenck commented 5 years ago

@scheric Yes, I have... The costs do show up in the app and on the Toon display. I guess it uses the graphs/data available from the data points, instead of the status call.

Onandon11 commented 5 years ago

@frenck, can we maybe help you test the new toon module? And I noticed in your previous post you don't have to give an API-key. Are you using the official API of Toon, and don't you need the API-key then?

scheric commented 5 years ago

@Onandon11 At this state the API-keys are hadrcoded in the Configuration.yaml

frenck commented 5 years ago

Current state:

image

image

I've released the PR for re-review.

NeuzNL commented 5 years ago

@frenck Is there a way to already install your add-on to my hass? I'm very curious how it works and how i can handle it myself.

frenck commented 5 years ago

@NeuzNL It is not an add-on, but a component. And is unfortunately not testable as a custom component (I guess that was your question?) The component uses the config flow, which is not available for custom components.

Onandon11 commented 5 years ago

@frenck, do you know when it will be released?

hmmbob commented 5 years ago

With 0.89, the next release. It's scheduled for next Wednesday.

CreatoX commented 5 years ago

Great job all! Just a little bit more patience until it is working again. Love this community!

Onandon11 commented 5 years ago

I see that the Toon component will be the RC of HA and will be released at 13 March. I thought that today would be the day. Nevertheless does this mean that it takes another 2 weeks after 13 March before all user get the update?

hmmbob commented 5 years ago

No, you just need to have a few more hours of patience. It will get released soon. Remember, this day is still long and the HA community is spread across the globe. HA is scheduled to release today.

jpduhen commented 5 years ago

That's nice. Can't wait to try the new Toon component ;-)