home_assistant_min_renovasjon
home_assistant_min_renovasjon copied to clipboard
Still error when connecting to komteksky.norkart.no whatever I do
Re issue 19, I've completely removed and reinstalled "Min Renovasjon" and whatever I do this error appear when turning on debugging:
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 293, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/min_renovasjon/sensor.py", line 33, in async_setup_entry calendar_list = await min_renovasjon.get_calendar_list() File "/config/custom_components/min_renovasjon/init.py", line 216, in get_calendar_list tommekalender, fraksjoner = await self._get_from_web_api() File "/config/custom_components/min_renovasjon/init.py", line 134, in _get_from_web_api tommekalender = await self._get_tommekalender_from_web_api() File "/config/custom_components/min_renovasjon/init.py", line 108, in _get_tommekalender_from_web_api async with session.get(url) as resp: File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection _, proto = await self._create_direct_connection(req, traces, timeout) File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection raise ClientConnectorError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host komteksky.norkart.no:443 ssl:default [Try again] 2023-03-19 10:29:48.422 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Min Renovasjon for sensor Traceback (most recent call last):
Any possibilities for more debugging info?
I might test with Postman if I can get a cURL-snippet or similar :)
Here's the complete cURL snippet for the failing request:
curl --location 'https://komteksky.norkart.no/komtek.renovasjonwebapi/api/tommekalender?gatenavn=Gatenavn&gatekode=9999&husnr=99'
--header 'Kommunenr: 9999'
--header 'RenovasjonAppKey: AE13DEEC-804F-4615-A74E-B4FAC11F0A30'
Substitute "gatenavn", "gatekode", "husnr" and header "kommunenr" with correct values. "gatekode" and "kommunenr" can be found using this request:
curl --location 'https://ws.geonorge.no/adresser/v1/sok?sok=Gatenavn%2099%2C%200001'
The parameter sok is the URL encoded address you're searching for. "gatekode" is called "adressekode" in the response.
Thank you. And of cause importing the snippet into Postman and then run it works flawlessly. :-)
I'm getting fractionids 2, 7, 1 and 4 with expected dates. So why it's not working from my HA (sitting on the same subnet) is a mystery. :(
Update: Still a mystery, but now it is working (restarted HA)! :-)
A theory: The first time I click on configure after adding the integration it seems like there is a timeout and I get a 500 error. When I click on configure once more I get the 4 fractions up for selection but no sensors when I select them and click on reload. Then I'm wondering: If I restart HA shortly after this, could it be that the DNS record is cached and since there is no timeout it works? While if the record is not cached it time out? I will test next time I loose the sensors! ;-)
Update: Yes, seems like the theory is ok... :)
I had a couple of updates that I installed and restarted HA, then the Min Renovasjon sensors were "unavailable". Tried to reload the integration without any luck (as usual), then I restarted HA once more and the integration worked again...
Just a suggestion: Could an automatic retry be implemented if this error appears? http.client_exceptions.ClientConnectorError: Cannot connect to host komteksky.norkart.no:443 ssl:default [Try again] (or a longer timeout).
Maybe the reason why this happens with me could be due to other integrations that takes a bit time to load...