Core: Toon is not working again :(

Created on 30 Oct 2019  路  29Comments  路  Source: home-assistant/core

Home Assistant release with the issue:
v0.100.3

Last working Home Assistant release (if known):
Not sure. Not working for me for the last 2 or 3 versions already

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

Integration:
https://www.home-assistant.io/integrations/toon/

Description of problem:
The issue is that toon integration stoped working for me since some time (a month or so).
Initially i was thinking that this is related to API limit, but the issue didn't disappear by itself.
Today i noticed, that API actually returns something, but looks like library cannot parse response properly? Please see trackback for more info.

Traceback (if applicable):

2019-10-30 09:14:18 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry eneco-001-334514 for toon
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 388, in _get_status_value
    output = self.status[value]
KeyError: 'gasUsage'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 190, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 83, in async_setup_entry
    toon_data = ToonData(hass, entry, toon)
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 125, in __init__
    self.gas = toon.gas
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 396, in gas
    usage = self._get_status_value('gasUsage')
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 390, in _get_status_value
    raise IncompleteStatus(self.status)
toonapilib.toonapilibexceptions.IncompleteStatus: {'thermostatStates': {'state': [{'id': 0, 'tempValue': 1650, 'dhw': 1}, {'id': 1, 'tempValue': 1650, 'dhw': 1}, {'id': 2, 'tempValue': 1600, 'dhw': 1}, {'id': 3, 'tempValue': 1200, 'dhw': 1}, {'id': 4, 'tempValue': 1300, 'dhw': 1}], 'lastUpdatedFromDisplay': 1572423258008}, 'thermostatInfo': {'currentSetpoint': 1200, 'currentHumidity': None, 'currentDisplayTemp': 1800, 'programState': 1, 'activeState': 3, 'nextProgram': 1, 'nextState': 0, 'nextTime': 1572454800, 'nextSetpoint': 1650, 'hasBoilerFault': 0, 'errorFound': 255, 'boilerModuleConnected': 1, 'realSetpoint': 1200, 'burnerInfo': '0', 'otCommError': '0', 'currentModulationLevel': 0, 'haveOTBoiler': 0, 'lastUpdatedFromDisplay': 1572423257761}, 'deviceConfigInfo': {'device': [{'devUUID': '4f788930-7ce8-4d47-9bd9-123faf6297b2', 'devType': 'NAS_WR01Z', 'name': 'NAS_WR01Z-1', 'flowGraphUuid': 'bef66d8c-78a8-4106-9c7e-3af9e144bfb4', 'quantityGraphUuid': '7ec115dd-669a-4ea8-b6fb-5d9a137226c4', 'position': 0, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 1, 'currentState': None, 'rgbColor': None, 'zwuuid': 'e82cdd72-a995-459f-a62e-ff9c66b0e35a'}], 'lastUpdatedFromDisplay': 1572423257228}, 'deviceStatusInfo': {'device': [{'devUUID': '4f788930-7ce8-4d47-9bd9-123faf6297b2', 'name': 'NAS_WR01Z-1', 'currentUsage': 0.0, 'dayUsage': 0.0, 'avgUsage': 0.0, 'currentState': 0, 'isConnected': 0, 'networkHealthState': 1, 'rgbColor': None}], 'inSwitchAllTotal': {'currentState': 0, 'currentUsage': 0.0, 'dayUsage': 0.0, 'avgUsage': 0.0}, 'lastUpdatedFromDisplay': 1572423257503}, 'powerUsage': {'value': 802, 'dayCost': 0.43, 'valueProduced': 0, 'dayCostProduced': None, 'valueSolar': 0, 'maxSolar': 0, 'dayCostSolar': None, 'avgSolarValue': None, 'avgValue': 404.46, 'avgDayValue': 9707.14, 'avgProduValue': 0, 'avgDayProduValue': None, 'meterReading': 1013875, 'meterReadingLow': 1375276, 'meterReadingProdu': 0, 'meterReadingLowProdu': 0, 'dayUsage': 1866, 'dayLowUsage': 2730, 'todayLowestUsage': None, 'isSmart': 1, 'lowestDayValue': 182, 'solarProducedToday': 0, 'lastUpdatedFromDisplay': 1572423258204}, 'lastUpdateFromDisplay': 1572423258206, 'serverTime': 1572423258338}

Additional information:
Taking into account my limited knowledge of Python i can conclude that response doesn't contain gasUsage key in response status dictionary (and indeed it doesn't). Did toon API change?

in progress toon

Most helpful comment

I've been making progress, most functionality is now in, fully async, with OAuth2 handling.

All 29 comments

Hey there @frenck, mind taking a look at this issue as its been labeled with a integration (toon) you are listed as a codeowner for? Thanks!

The reason why I have refactored Toon initial quite a while back is that I have a Toon myself 馃槈

I've not been able to reproduce the issue to be honest.

Do you have a gas meter hooked up to Toon? If so, can you read it via the display? And if yes, do the numbers on the display match the meter? The Toon app?

Both Toon and Toon app shows numbers perfectly.
I have a smart meters (now analog + laser reader. Eneco installed them half a year ago) and Toon integration did work for a while, but now it's dead :(

I have the same issue as aalbul, same error messages in the log etc. , also for the last 2/3 versions!

As of yesterday, the issue started appearing in my own setup as well.
Are they rolling out changes in phases or something? Seems like the gas usage has been removed from the API?

I might need to take this up with the author of the ToonAPILib, that powers this integration.

So it started working again... At this point, looking at the responses, I feel like this was a glitch at Cuby end?

Indeed, it works. However, i don't see "Current Gas" anymore. It is always at 0.
Screenshot 2019-11-18 at 12 32 28

Agreed, @aalbul, I see the same, however, this is the value returned by Toon/Eneco/Quby.

I've run some raw tests against their API, and the value always returns 0. So this part is currently out of my control. If it stays this way, I think the only option is to remove the sensor.

Sure, this is definitely must be solved on API / API bindings level.
Maybe you should document this issue in Toon component?
Can save your from a lot of questions like that :)

I am having the same issue.
It has never worked for me (using Toon for over a month now).

But I might have a diferent usage, I do not have any gas. I have 'Stadsverwarming' (District Heating).

Is there a way I can get it to work?
Or can I contribute to the integrations by sending data/logs etc.?

I am getting the following error(s):

2019-11-29 11:24:25 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry qb-659916001601-1933a0g8k6 for toon
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 388, in _get_status_value
    output = self.status[value]
KeyError: 'gasUsage'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 192, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 83, in async_setup_entry
    toon_data = ToonData(hass, entry, toon)
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 125, in __init__
    self.gas = toon.gas
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 396, in gas
    usage = self._get_status_value('gasUsage')
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 390, in _get_status_value
    raise IncompleteStatus(self.status)
toonapilib.toonapilibexceptions.IncompleteStatus: {'thermostatStates': {'state': [{'id': 0, 'tempValue': 2000, 'dhw': 1}, {'id': 1, 'tempValue': 1900, 'dhw': 1}, {'id': 2, 'tempValue': 1500, 'dhw': 1}, {'id': 3, 'tempValue': 1200, 'dhw': 1}, {'id': 4, 'tempValue': 600, 'dhw': 1}], 'lastUpdatedFromDisplay': 1575017696105}, 'thermostatInfo': {'currentSetpoint': 1950, 'currentHumidity': 41, 'currentDisplayTemp': 1950, 'programState': 2, 'activeState': -1, 'nextProgram': 1, 'nextState': 0, 'nextTime': 1575046800, 'nextSetpoint': 2000, 'hasBoilerFault': 0, 'errorFound': 255, 'boilerModuleConnected': 1, 'realSetpoint': 1950, 'burnerInfo': '0', 'otCommError': '0', 'currentModulationLevel': 0, 'haveOTBoiler': 1, 'lastUpdatedFromDisplay': 1575022945233}, 'smokeDetectors': {'device': [], 'lastUpdatedFromDisplay': 1575017697837}, 'deviceConfigInfo': {'device': [], 'lastUpdatedFromDisplay': 1575017695576}, 'deviceStatusInfo': {'device': [], 'inSwitchAllTotal': {'currentState': 0, 'currentUsage': 0.0, 'dayUsage': 0.0, 'avgUsage': 0.0}, 'lastUpdatedFromDisplay': 1575017695750}, 'powerUsage': {'value': 105, 'dayCost': 0.0, 'valueProduced': 0, 'dayCostProduced': None, 'valueSolar': 0, 'maxSolar': 0, 'dayCostSolar': None, 'avgSolarValue': None, 'avgValue': 244.57, 'avgDayValue': 5869.57, 'avgProduValue': 0, 'avgDayProduValue': None, 'meterReading': 3664298, 'meterReadingLow': 3550999, 'meterReadingProdu': 0, 'meterReadingLowProdu': 0, 'dayUsage': 637, 'dayLowUsage': 1074, 'todayLowestUsage': None, 'isSmart': 1, 'lowestDayValue': 102, 'solarProducedToday': 0, 'lastUpdatedFromDisplay': 1575023056276}, 'heatUsage': {'value': 0, 'dayCost': 150.67, 'avgValue': 435.24, 'meterReading': 62909, 'avgDayValue': 10445.8, 'dayUsage': 6278, 'isSmart': 0, 'lastUpdatedFromDisplay': 1575022975173}, 'waterUsage': {'installed': 0, 'value': 0, 'dayCost': 0, 'avgDayValue': None, 'avgValue': None, 'dayUsage': 0, 'meterReading': 0, 'isSmart': 0, 'lastUpdatedFromDisplay': 1575017697495}, 'lastUpdateFromDisplay': 1575023065645, 'serverTime': 1575023065714}

I have the same problem as well. It popped up, went away, and now it is back again.

homeassistant      | Traceback (most recent call last):
homeassistant      |   File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 388, in _get_status_value
homeassistant      |     output = self.status[value]
homeassistant      | KeyError: 'gasUsage'
homeassistant      |
homeassistant      | During handling of the above exception, another exception occurred:
homeassistant      |
homeassistant      | Traceback (most recent call last):
homeassistant      |   File "/usr/src/homeassistant/homeassistant/config_entries.py", line 192, in async_setup
homeassistant      |     hass, self
homeassistant      |   File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 83, in async_setup_entry
homeassistant      |     toon_data = ToonData(hass, entry, toon)
homeassistant      |   File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 125, in __init__
homeassistant      |     self.gas = toon.gas
homeassistant      |   File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 396, in gas
homeassistant      |     usage = self._get_status_value('gasUsage')
homeassistant      |   File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 390, in _get_status_value
homeassistant      |     raise IncompleteStatus(self.status)
homeassistant      | toonapilib.toonapilibexceptions.IncompleteStatus: 

...and a restart just fixed it again...

Same issue here, there is no way i can get Toon to work in Homeassistant, on configuration (after adding to configuration.yaml) it shows my credentials are incorrect (which are not). The toon app does function, and shows data.

It this a generic issue? Or is it something in my setup, i also have 'stadsverwarming' i'm willing to help out for improvements on that part (if needed).

Same issue here, there is no way i can get Toon to work in Homeassistant, on configuration (after adding to configuration.yaml) it shows my credentials are incorrect (which are not). The toon app does function, and shows data.

It this a generic issue? Or is it something in my setup, i also have 'stadsverwarming' i'm willing to help out for improvements on that part (if needed).

Same problem here and with my friend after he logged out for me to try my account.
I also found more people on different forum who got the same problem.
So i know 100% for sure its not my account.

For the one who can program a bit the problem is in the libary i think.
All the versions dont let toon to work.
Also tryed different HA setups.
No succes.
Users got a error: unknown user credentials. After the input in toon username/password/tenant..(eneco). I would like to give a big donation if we get this to work again.
regards,
Tim

I have the same problem.
it stopped working a few days ago. restarting doesn't solve anything.
i'm running HA 0.105.5.

log:

2020-02-22 17:23:42 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry qb-659916001600-1802a016x8 for toon
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 256, in status
data = response.json()
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python3.7/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)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 215, in async_setup
hass, self
File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 83, in async_setup_entry
toon_data = ToonData(hass, entry, toon)
File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 125, in __init__
self.gas = toon.gas
File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 396, in gas
usage = self._get_status_value('gasUsage')
File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 388, in _get_status_value
output = self.status[value]
File "/usr/local/lib/python3.7/site-packages/cachetools/__init__.py", line 46, in wrapper
v = func(args, *kwargs)
File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 259, in status
raise IncompleteStatus
toonapilib.toonapilibexceptions.IncompleteStatus

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Hi. It is stable (at least doesn't fail), though, daily gas metrics are not working for me for a long time. Current gas works fine.

For me it is not working at all. I'm still getting the gasUsage error.
Running 0.110.2

Log Details (ERROR)
Logger: homeassistant.config_entries
Source: components/toon/__init__.py:125
First occurred: 9:21:43 AM (1 occurrences)
Last logged: 9:21:43 AM

Error setting up entry eneco-001-109832 for toon
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 388, in _get_status_value
    output = self.status[value]
KeyError: 'gasUsage'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 83, in async_setup_entry
    toon_data = await hass.async_add_executor_job(ToonData, hass, entry, toon)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/toon/__init__.py", line 125, in __init__
    self.gas = toon.gas
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 396, in gas
    usage = self._get_status_value('gasUsage')
  File "/usr/local/lib/python3.7/site-packages/toonapilib/toonapilib.py", line 390, in _get_status_value
    raise IncompleteStatus(self.status)
toonapilib.toonapilibexceptions.IncompleteStatus: {'thermostatInfo': {'currentSetpoint': 2000, 'currentHumidity': None, 'currentDisplayTemp': 2250, 'programState': 1, 'activeState': 1, 'nextProgram': 1, 'nextState': 2, 'nextTime': 1590435000, 'nextSetpoint': 1500, 'hasBoilerFault': 0, 'errorFound': 255, 'boilerModuleConnected': 1, 'realSetpoint': 2000, 'burnerInfo': '0', 'otCommError': '0', 'currentModulationLevel': 0, 'haveOTBoiler': 0, 'lastUpdatedFromDisplay': 1590384304460, 'setByLoadShifting': 0}, 'deviceConfigInfo': {'device': [{'devUUID': '9e6c1bd8-560a-4611-9759-cbd9a071286e', 'devType': 'hue_light-LCT003', 'name': 'Serre spot 2 - midden', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 0, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'fad60951-38e6-47eb-916e-79afe2043bec'}, {'devUUID': '98bd27e0-30fe-43c6-a952-ff147e40d65b', 'devType': 'hue_light-LCT003', 'name': 'Serre spot 1 - tv', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 1, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': '694c0f7d-f231-444f-9e42-c7f93ae51d0a'}, {'devUUID': '9f1014ec-20fe-4114-aa51-a8459ac715ac', 'devType': 'hue_light-LCT003', 'name': 'Serre spot 3 - dressoir', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 2, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'd394eb62-f1b3-4f8e-bc20-9efd72b21405'}, {'devUUID': '9a6baabb-205b-4619-9742-8f60bf856dda', 'devType': 'hue_light-LCT003', 'name': 'Haardspot', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 3, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': '9bd2ae28-32a2-43d2-aa24-63de768f55ce'}, {'devUUID': 'd429e605-72df-4668-9f90-6e3f2ebaf7fe', 'devType': 'hue_light-LWG001', 'name': 'Gang Spot 1 - trap', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 4, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'dd4452e2-3d63-4dfa-ae48-b32584ea12db'}, {'devUUID': '790ebb7a-b4bc-43c1-a715-31cfb55d819a', 'devType': 'hue_light-LWG001', 'name': 'Gang Spot 3 - Voordeur', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 5, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'bc8bcd62-d81e-4722-89a2-0a1c4c369401'}, {'devUUID': 'a25e1882-1685-41bc-9847-80804cab069b', 'devType': 'hue_light-LWG001', 'name': 'Gang Spot 2 - midden', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 6, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'f20230ff-605a-4280-bfee-cb89492b083d'}, {'devUUID': '24855b63-f908-4be5-836a-3e8958af6382', 'devType': 'hue_light-LST002', 'name': 'TV Light', 'flowGraphUuid': None, 'quantityGraphUuid': None, 'position': 7, 'inSwitchAll': 1, 'inSwitchSchedule': 0, 'switchLocked': 0, 'usageCapable': 0, 'currentState': None, 'rgbColor': None, 'zwuuid': 'eae09387-a815-4a16-a2fa-6028d28d77af'}], 'lastUpdatedFromDisplay': 1590391303252}, 'deviceStatusInfo': {'device': [{'devUUID': '9e6c1bd8-560a-4611-9759-cbd9a071286e', 'name': 'Serre spot 2 - midden', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': '130A01'}, {'devUUID': '98bd27e0-30fe-43c6-a952-ff147e40d65b', 'name': 'Serre spot 1 - tv', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': '130A01'}, {'devUUID': '9f1014ec-20fe-4114-aa51-a8459ac715ac', 'name': 'Serre spot 3 - dressoir', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': '130A01'}, {'devUUID': '9a6baabb-205b-4619-9742-8f60bf856dda', 'name': 'Haardspot', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': '130A01'}, {'devUUID': 'd429e605-72df-4668-9f90-6e3f2ebaf7fe', 'name': 'Gang Spot 1 - trap', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': 'FFEB99'}, {'devUUID': '790ebb7a-b4bc-43c1-a715-31cfb55d819a', 'name': 'Gang Spot 3 - Voordeur', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': 'FFEB99'}, {'devUUID': 'a25e1882-1685-41bc-9847-80804cab069b', 'name': 'Gang Spot 2 - midden', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': 'FFEB99'}, {'devUUID': '24855b63-f908-4be5-836a-3e8958af6382', 'name': 'TV Light', 'currentUsage': None, 'dayUsage': None, 'avgUsage': None, 'currentState': 0, 'isConnected': 1, 'networkHealthState': None, 'rgbColor': '130A01'}], 'inSwitchAllTotal': {'currentState': 0, 'currentUsage': 0.0, 'dayUsage': 0.0, 'avgUsage': 0.0}, 'lastUpdatedFromDisplay': 1590391303453}, 'powerUsage': {'value': 173, 'dayCost': 0.02, 'valueProduced': 0, 'dayCostProduced': None, 'valueSolar': 173, 'maxSolar': 1658, 'dayCostSolar': None, 'avgSolarValue': 310.71, 'avgValue': 456.36, 'avgDayValue': 10952.71, 'avgProduValue': 160.47, 'avgDayProduValue': 3851.29, 'meterReading': 9530174, 'meterReadingLow': 11806576, 'meterReadingProdu': 377922, 'meterReadingLowProdu': 143653, 'dayUsage': 76, 'dayLowUsage': 1826, 'todayLowestUsage': None, 'isSmart': 1, 'lowestDayValue': 165, 'solarProducedToday': 100, 'lastUpdatedFromDisplay': 1590384261244}, 'lastUpdateFromDisplay': 1590391303454, 'serverTime': 1590391303593}

I just checked and i'm still getting an error during login add of the integration. There are also Github issues present, which are still open.

Still got same problem.. Cannot login. As i heard from @frenck The whole libary needs to rewritten... Dont know the progress of that...

I've been making progress, most functionality is now in, fully async, with OAuth2 handling.

PR is open to replace the integration in #36952

Hi,

Even though the new integration is out, i cannot use it....

For now i faced 2 issues:

  1. I specify correct URL in Toon development portal, but redirect happens to it without port
  2. When i manually specify port, the redirect successfully happens, but then i get such an error:
Logger: aiohttp.server
Source: components/toon/oauth2.py:134
First occurred: 9:33:26 PM (1 occurrences)
Last logged: 9:33:26 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in get
    return await super().get(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 92, in get
    result = await self._flow_mgr.async_configure(flow_id)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 153, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 201, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 259, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(self.external_data)
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 104, in async_resolve_external_data
    return await self._token_request(data)
  File "/usr/src/homeassistant/homeassistant/components/toon/oauth2.py", line 134, in _token_request
    resp.raise_for_status()
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 946, in raise_for_status
    headers=self.headers)
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url='https://api.toon.eu/token

Ok, problem solved. The redirect issue was related to the fact, that i had wrong internal_url specified. By changing it to the right one, problem was fixed.

Ok, problem solved. The redirect issue was related to the fact, that i had wrong internal_url specified. By changing it to the right one, problem was fixed.

@aalbul : Today I set this up for the first time, but get an "invalid redirect" error when configuring the Toon integration. Can you please provide an example of a working Callback URL in the Toon developer app config? The one I'm trying is: "https://:8123/auth/external/callback" (based on the example in the Toon release documentation).
Any additional setup necessary in e.g. HA (other than id and secret in config.yaml), router or firewall?

For me it looks like that:
Screenshot 2020-07-10 at 15 00 08
Please note, that http://hassio.nemesis.local/auth/external/callback is my local dns name. Basically, even "localhost" will work for you. You should understand, that it's a redirect URL for your browser. Toon service will not try to call it. It will just send it to you as a redirect url.
In other words, if it works for your in your browser, then you are fine. No need in any special router/firewall configuration

In other words, if it works for your in your browser, then you are fine.

@aalbul I never had such a quick response, was still reaching for the coffee and the reply was in. Merci!
Problem was that extra "s" in "https" vs "http", as SSL is not enabled in my setup.

In other words, if it works for your in your browser, then you are fine.

@aalbul I never had such a quick response, was still reaching for the coffee and the reply was in. Merci!
Problem was that extra "s" in "https" vs "http", as SSL is not enabled in my setup.

Hope that solved your problem :)
Quick response can be explained quite simple: i am a software dev and i have a github notifications to my email that i read all the time :D

Ok, problem solved. The redirect issue was related to the fact, that i had wrong internal_url specified. By changing it to the right one, problem was fixed.

@aalbul : Today I set this up for the first time, but get an "invalid redirect" error when configuring the Toon integration. Can you please provide an example of a working Callback URL in the Toon developer app config? The one I'm trying is: "https://:8123/auth/external/callback" (based on the example in the Toon release documentation).
Any additional setup necessary in e.g. HA (other than id and secret in config.yaml), router or firewall?

For me it looks like that:
Screenshot 2020-07-10 at 15 00 08
Please note, that http://hassio.nemesis.local/auth/external/callback is my local dns name. Basically, even "localhost" will work for you. You should understand, that it's a redirect URL for your browser. Toon service will not try to call it. It will just send it to you as a redirect url.
In other words, if it works for your in your browser, then you are fine. No need in any special router/firewall configuration

If you're running HA on a FQDN, the callback url in the link to finish the integration gets changed to the internal IP address of your server. You need to configure that local IP address instead of your FQDN in the Toon Developer app as internal_url.

E.g. https://home.example.com gets changed to https://192.168.xxx.xxx

Was this page helpful?
0 / 5 - 0 ratings