Home Assistant cannot connect to WEM3080 after power outage

Hi, I have an issue after power outage. When power is restored, the following sequence of events is observed.

Similar issue reported in GITHUB but was closed unactioned (https://github.com/home-assistant/core/issues/68262)

1. WEM3080 comes online before WIFI router, goes into AP mode

2. WIFI router comes online, Home Assistant comes online

Home Assistant tries to communicate with WEM3080, but cannot find it because it's gone into AP mode

Following is error log from home assistant.


2022-05-25 15:05:41 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up iammeter platform for sensor
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.5.112', 80)

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 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/src/homeassistant/homeassistant/components/iammeter/sensor.py", line 56, in async_setup_platform
api = await real_time_api(config_host, config_port)
File "/usr/local/lib/python3.9/site-packages/iammeter/__init__.py", line 38, in real_time_api
i = await power_meter.discover(ip_address, port)
File "/usr/local/lib/python3.9/site-packages/iammeter/power_meter.py", line 80, in discover
async with session.get(url) as resp:
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.5.112:80 ssl:default [Connect call failed ('192.168.5.112', 80)]



Thread Status
11
484
3
2
0

Sort replies by:

In fact ,we really want to update our integration in HA, there are to many features that need to be updated into our integration (device discovery,support the new "energy management component " ,handle the exception like this etc ..)
But it is hard to merge any code in since nearly two years ago.
We try to submit several PR, but just one PR gets a reviewer but still can not move just one step forward, others are all halted at the first step.
The PRs had been waiting for nearly one year.
It seems we can not merge any PR into the home assistant now.
We do not know why and also do not know how to resolve this problem.

Thank you Laoliu. Agree 10 minutes is acceptable for WEM3080.However, Home Assistant fails to connect during this time and gives up to retry. Please see below error log from HA.Actually the outage in this situation is, until Home Assistant is manually restarted.Can this be improved in the Home Assistant integration?022-05-25 15:05:41 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up iammeter platform for sensorTraceback (most recent call last):  File "/usr/local/li

This is some PR history 

https://github.com/home-assistant/core/issues?q=iammeter+label%3A%22integration%3A+iammeter%22+author%3Alewei50


It seems the latest PR had been closed by the bot.
I will let my colleague submit a new PR again.
Then I will post the PR URL here.
So appreciate it if you can contact the reviewer of the Home assistant.
We know there are so many PR that waited for them to review.

I remember they restrict that one PR can only about one feature, I think this will also lead to a large PRs quantity

Anyway, we will submit a new PR soon, It will be so appreciated if it can be reviewed.


Hi:

The reconnect logic of the energy meter is as below.

if it can not connect the router successfully when it is power up, it will enter ap mode.
it will try to reconnect to the router every 10 mins. Once it connects successfully, it will enter the sta mode, and the SSID of iMeter_sn would disappear.

So it will only affect about 10 mins data reading.
Considering that power outage is not common,so I think the 10 mins data gap after the power recovery is acceptable.

Thank you Laoliu. Agree 10 minutes is acceptable for WEM3080.

However, Home Assistant fails to connect during this time and gives up to retry. 

Please see below error log from HA.

Actually the outage in this situation is, until Home Assistant is manually restarted.

Can this be improved in the Home Assistant integration?


022-05-25 15:05:41 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up iammeter platform for sensor
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.5.112', 80)

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 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/src/homeassistant/homeassistant/components/iammeter/sensor.py", line 56, in async_setup_platform
api = await real_time_api(config_host, config_port)
File "/usr/local/lib/python3.9/site-packages/iammeter/__init__.py", line 38, in real_time_api
i = await power_meter.discover(ip_address, port)
File "/usr/local/lib/python3.9/site-packages/iammeter/power_meter.py", line 80, in discover
async with session.get(url) as resp:
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.5.112:80 ssl:default [Connect call failed ('192.168.5.112', 80)]

Hi:The reconnect logic of the energy meter is as below.if it can not connect the router successfully when it is power up, it will enter ap mode.it will try to reconnect to the router every 10 mins. Once it connects successfully, it will enter the sta mode, and the SSID of iMeter_sn would disappear.So it will only affect about 10 mins data reading.Considering that power outage is not common,so I think the 10 mins data gap after the power recovery is acceptable.

Hi Laoliu,

I see, thank you! I'd like to help.

Do you have any links for PR in github that I may use when communicating with Home Assistant reviewers?


Cheers

Barny

In fact ,we really want to update our integration in HA, there are to many features that need to be updated into our integration (device discovery,support the new "energy management component " ,handle the exception like this  etc ..)But it is hard to merge any code in since nearly two years ago.We try to submit several PR, but just one  PR gets a reviewer but still can not move just one step forward, others are all halted at the first step.The PRs had been waiting for nearly one year.It seems w

I've raised an issue on github.

@laoliu Can you respond to it? Then we can push the HA reviewers

This is some PR history https://github.com/home-assistant/core/issues?q=iammeter+label%3A%22integration%3A+iammeter%22+author%3Alewei50It seems the latest PR had been closed by the bot.I will let my colleague submit a new PR again.Then I will post the PR URL here.So appreciate it if you can contact the reviewer of the Home assistant.We know there are so many PR that waited for them to review.I remember they restrict that one PR can only about one feature, I think this will also lead to a la

Sorry link here:

https://github.com/home-assistant/core/issues/72736

I've raised an issue on github.@laoliu Can you respond to it? Then we can push the HA reviewers

OK, I have forwarded this to my colleague, he will respond tomorrow, thanks again.

The only way I can get Iammeter to talk to HA after a restart of any WiFI hub or the WEM380T is to restart HA.  Otherwise it never reconnects if it ever loses connection.  I can see the Iammeter app working in the web browser etc, its just the HA integration

Hi, 

We have always tried to upgrade our HA integration since the first merging.

But never successfully, 

This is our latest PR.

https://github.com/home-assistant/core/pull/73199

Looks like you are new here. Register for free, learn and contribute.