Home Assistant integration not working next day

Hi, I've integrated iammeter into Home Assistant as per the tutorials.
First day working fine.

Second day 0 data. I can Ping the WEM3080 IP address, no issues there.

When I curl the IP address/monitorjson, it returns 401 Unauthorized.

Do I need to somehow add the authorization token for Home assistant?

I notice the OpenHAB integration requires the token Authorization=Basic YWRtaW46YWRtaW4=.

Is this needed for Home Assistant too?

Thread Status
6
55
3
2
0

Sort replies by:

"I notice the OpenHAB integration requires the token Authorization=Basic YWRtaW46YWRtaW4=."

Yes, it is the basic auth with 

user name: admin

pwd: admin


Just input such parameters in the prompt of the browser and you will get the return of monitorjson in the browser.

The Home assistant also needs to achieve such basic auth.

But in my opinion, we have already implemented this basic auth in the integration of IAMMETER, otherwise, no data will be returned.



You can look at the log of your homeassistant, or provide more detailed data, which data has become 0, determine whether it is 0 or the device is offline, then what is the historical curve? To help you figure out what the problem is

Yes thank you. I have confirmed when it is working, the token is being sent.

Since then, I still have 2 problems:

Problem #1. When there is blackout and power comes back on, WEM3080 powers up before WIFI is available and seems to go into 'access point' mode where SSID is imeter-9xxxxxxxx. Then, WIFI comes back, but it's too late, WEM3080 is in access point mode and doesn't connect to WIFI.

To remedy this, I have to manually disconnect power from WEM3080 and reconnect power. Is this normal?

Problem #2. When this happens, HA cannot find WEM3080, which is normal. I get the following error below from HA error log.

But HA does not continue to poll for WEM3080, it gives up. Because even after WEM3080 comes back on WIFI, HA does not connect to it.

HA must be restarted manually to resume connection to WEM3080. Can this be fixed somehow?

"I notice the OpenHAB integration requires the token Authorization=Basic YWRtaW46YWRtaW4=."Yes, it is the basic auth with user name: adminpwd: adminJust input such parameters in the prompt of the browser and you will get the return of monitorjson in the browser.The Home assistant also needs to achieve such basic auth.But in my opinion, we have already implemented this basic auth in the integration of IAMMETER, otherwise, no data will be returned.

Thanks. After some further poking around, I found 2 issues in thread highlighted to laoliu.

Basically 0 data because WEM3080 went into AP mode, because power was lost and WIFI router boots up slower and hence no WIFI yet.

You can look at the log of your homeassistant, or provide more detailed data, which data has become 0, determine whether it is 0 or the device is offline, then what is the historical curve? To help you figure out what the problem is

Sorry forgot to attach this error log for Problem #2

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)]

Yes thank you. I have confirmed when it is working, the token is being sent.Since then, I still have 2 problems:Problem #1. When there is blackout and power comes back on, WEM3080 powers up before WIFI is available and seems to go into 'access point' mode where SSID is imeter-9xxxxxxxx. Then, WIFI comes back, but it's too late, WEM3080 is in access point mode and doesn't connect to WIFI.To remedy this, I have to manually disconnect power from WEM3080 and reconnect power. Is this normal?Problem #

For offline problems, you may check whether the meter is always connected to the router. For the occasional data 0, you can refer to here: https://imeter.club/topic/77

  - sensor:
- name: "Grid consumption energy (general tariff)"
unit_of_measurement: 'kWh'
device_class: energy
state_class: total_increasing
state: >-
{% if states('sensor.iammeter1_importenergy') in ['unavailable', 'unknown', 'none', 0] %}
{{
states('sensor.grid_consumption_energy_general_tariff')|float
}}
{% elif states('sensor.iammeter1_importenergy')|float < states('sensor.grid_consumption_energy_general_tariff')|float %}
{{
states('sensor.grid_consumption_energy_general_tariff')|float
}}
{% else %}
{{
states('sensor.iammeter1_importenergy')|float
}}
{% endif %}

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