myTselection / telenet_telemeter

Telenet Telemeter Home Assistant custom component HACS for Belgian ISP and mobile phone network traffic.
MIT License
30 stars 6 forks source link

0.2.0 Seems broken after upgrade from 0.1.1 #8

Closed teranex closed 1 year ago

teranex commented 1 year ago

Yesterday I upgraded to 0.2.0 and HA started telling me the 'Telenet Telemeter' entity is unavailable. I just downgraded to 0.1.1 and now it works again.

The only thing I could see in the logs after running 0.2.0 with debug logging:

2023-01-18 21:54:40.259 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Telenet Telemeter for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 573, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 166, in async_setup_entry
    raise ValueError("Config entry has already been setup!")
ValueError: Config entry has already been setup!
teranex commented 1 year ago

As a test I just upgraded again from 0.1.1 to 0.2.0 and the entity is again showing up as Unavailable

myTselection commented 1 year ago

Could you remove it (from 'Settings' > 'Devices and services') and set it up again? Re-entering your credentials. As since r0.2.0 extra sensor is created

teranex commented 1 year ago

That didn't solve it. I removed the integration (settings > integrations > telenet telemeter > delete). Then added it again. First I tried with only selecting internet (no mobile as I don't use Telenet Mobile). The integration was added again but completely empty (no entities or devices at all).
Then I removed the integration again and added it again with both internet and mobile checked, but that had the same result. From the logs:

2023-01-19 23:00:03.813 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up telenet_telemeter platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/telenet_telemeter/sensor.py", line 85, in async_setup_entry
await dry_setup(hass, config, async_add_devices)
File "/config/custom_components/telenet_telemeter/sensor.py", line 65, in dry_setup
await data_mobile._init()
File "/config/custom_components/telenet_telemeter/sensor.py", line 126, in _init
self._mobilemeter = await self._hass.async_add_executor_job(lambda: self._session.mobile())
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/telenet_telemeter/sensor.py", line 126, in <lambda>
self._mobilemeter = await self._hass.async_add_executor_job(lambda: self._session.mobile())
File "/config/custom_components/telenet_telemeter/utils.py", line 117, in mobile
assert response.status_code == 200
AssertionError
teranex commented 1 year ago

hmmm I just tested it one more time: I removed the integration again and created it again with only 'internet' checked. Now it seems to have been created correctly. The integration again shows 1 device with 1 entity. And i see the percentage gauge agan :)

teranex commented 1 year ago

I guess when a person does not have a mobile subscription (which is way to expensive and beyond terrible signal strength in Antwerp-North), Telenet does not return a http 200 when requesting the data, thus causing the assertion to fail.

myTselection commented 1 year ago

I guess when a person does not have a mobile subscription (which is way to expensive and beyond terrible signal strength in Antwerp-North), Telenet does not return a http 200 when requesting the data, thus causing the assertion to fail.

I noticed yesterday the Telenet servers did had some hickups. After retrying myself too, it didn't work at first but later yesterday evening it worked again without any code changes. I don't have Telenet mobile neither (I have just created another custom integration to get Youfone.be mobile data into HA, which is way more cheaper and using Proximus network). I checked the code again and I can confirm, if mobile is not enabled, no mobile specific requests will be executed. So for now I will close this ticket, probably bad luck on timing with unstability at Teletnet backend servers.

teranex commented 1 year ago

It is working without problems now. Thank you for this very useful integration!