home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.65k stars 30.79k forks source link

"Failed to connect" Shelly3em #48122

Closed doronazl closed 3 years ago

doronazl commented 3 years ago

The problem

my HA suddenly showed 0W from SHELLY3EM everything looked in order on HA but still got nothing i went to shelly app and was getting readings as usuall

so i deleted the integration from HA and tried to add it again. ever since i did that i cant get it back on HA HA will discover shelly 3em but when trying to add it getting error FAILED TO CONNECT tried factory default, rebooting everything related to it, router,shelly,ha, even changed the device ip to another, still same.

What is version of Home Assistant Core has the issue?

core-2021.3.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

shelly

Link to integration documentation on our website

No response

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line
dodg3r commented 3 years ago

Hi. I can confirm. It´s same for me. I enabled debug and this shows i log repeatedly. "Elcentral" is the name of my shelly 3EM.

2021-03-19 18:31:09 DEBUG (MainThread) [homeassistant.components.shelly] Setting up online device Elcentral

I dont know if this helps you. This is log from shelly 3EM.

409981759 mgos_http_server.c:180  0x3fff4a4c HTTP connection from 192.168.1.X:59208
410013810 mgos_http_server.c:180  0x3fff49d4 HTTP connection from 192.168.1.X:59210
410057167 mgos_http_server.c:180  0x3fff4a8c HTTP connection from 192.168.1.X:59212
410074403 json.c:412              RAM: 48800 total, 29288 free
mib1185 commented 3 years ago

Hi @doronazl just to be on same side - does this issue started after an update of HA (if yes, which versions was working before) or after an firmware update of the Shelly 3em (which version is currently running on it)?

dodg3r commented 3 years ago

Hi.

Sorry. I just thought that this was the same error as me. For me this started after shelly firmware update to v.1.10. But wait for doronazl answer...Maybe I have to start my own issue :)

doronazl commented 3 years ago

Hi @doronazl just to be on same side - does this issue started after an update of HA (if yes, which versions was working before) or after an firmware update of the Shelly 3em (which version is currently running on it)?

Ok so i dont know fhe exact time it started but i did update all my shellys today, like 14 total and noticed this a few hours later I didn't do an update for HA for a while now, at least a few days i think Shelly Is currently on 1.10

doronazl commented 3 years ago

Hi. I can confirm. It´s same for me. I enabled debug and this shows i log repeatedly. "Elcentral" is the name of my shelly 3EM.

2021-03-19 18:31:09 DEBUG (MainThread) [homeassistant.components.shelly] Setting up online device Elcentral

I dont know if this helps you. This is log from shelly 3EM.

409981759 mgos_http_server.c:180  0x3fff4a4c HTTP connection from 192.168.1.X:59208
410013810 mgos_http_server.c:180  0x3fff49d4 HTTP connection from 192.168.1.X:59210
410057167 mgos_http_server.c:180  0x3fff4a8c HTTP connection from 192.168.1.X:59212
410074403 json.c:412              RAM: 48800 total, 29288 free

My log doesn't seem to show anything similar, u referring to shelly debug log?

doronazl commented 3 years ago

Update : Reverted to an older version of shelly and its back working now. 1.9.4

mib1185 commented 3 years ago

I have done some tests with an "Shelly Plug S" on version 20210318-141150/v1.10.0-geba262d without issues. But to be honest, I´m not sure how different these both peaces of hardware are 🤔

dodg3r commented 3 years ago

I have about 30 devices that works with v1.10 but its just 3EM that doesnt work

mib1185 commented 3 years ago

Mhhh 🤔 Are there any additional entries in HA logs shown/visible related to shelly integration?

Your debug log lines from shelly seems to be usual, because I see similar logs on my "Shelly Plug S":

728200944 shelly_power_meter.:195 *** pulses[48906] power[36.28]
728528858 mgos_http_server.c:180  0x3fff234c HTTP connection from 192.168.1.5:55744
728545977 json.c:412              RAM: 50632 total, 37748 free
dodg3r commented 3 years ago

Only this:

2021-03-19 18:31:09 DEBUG (MainThread) [homeassistant.components.shelly] Setting up online device Elcentral

xhe9 commented 3 years ago

How about this just send a secure link to remove it completely

On Fri, Mar 19, 2021 at 3:37 PM Jerry Johansson @.***> wrote:

Only this:

2021-03-19 18:31:09 DEBUG (MainThread) [homeassistant.components.shelly] Setting up online device Elcentral

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/48122#issuecomment-803068062, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATH34TN5I3VUIVOUC5SXFMDTEORXHANCNFSM4ZPEE5YA .

mib1185 commented 3 years ago

OK ... I have had a look into the code, only an asyncio.TimeoutError or aiohttp.ClientError error would result in "Failed to Connect", all other would result in "Unknown error" ... so now the question is - what is the current cause ... timeout or clienterror 🤔 Unfortunately, there are no debug messages implemented in shelly integration at this step 😕

dodg3r commented 3 years ago

How about this just send a secure link to remove it completely On Fri, Mar 19, 2021 at 3:37 PM Jerry Johansson @.***> wrote: Only this: 2021-03-19 18:31:09 DEBUG (MainThread) [homeassistant.components.shelly] Setting up online device Elcentral — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#48122 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATH34TN5I3VUIVOUC5SXFMDTEORXHANCNFSM4ZPEE5YA .

I dont know what you mean by that?

mib1185 commented 3 years ago

I have added some additional debug logs to shelly integration - it is available in my own fork here https://github.com/mib1185/homeassistant-core/tree/shelly_additional-debug Could you please load the shelle integration out of it as custom component into your HA, enable debug logging for custom_components.shelly and than retry to add the 3em device?

dodg3r commented 3 years ago

Do you know if there is a guide for that. I´ve never loaded integrations as custom components before.

mib1185 commented 3 years ago

In https://github.com/home-assistant/core/issues/42878#issuecomment-778611493 I have written a short howot, but for synology_dsmintegration, so this needs to be adapted to shelly integration. If this howto does not work for you, than I will rewrite it for the current situation.

dodg3r commented 3 years ago

I have a dev installation that I´m testing on. When I´m trying to add shelly 3EM it says that i fails to connect and this shows in log:

2021-03-19 21:32:40 ERROR (MainThread) [custom_components.shelly.config_flow] Exception of type (<class 'asyncio.exceptions.TimeoutError'>, <class 'aiohttp.client_exceptions.ClientError'>) observed
Traceback (most recent call last):
  File "/config/custom_components/shelly/config_flow.py", line 42, in validate_input
    device = await aioshelly.Device.create(
  File "/usr/local/lib/python3.8/site-packages/aioshelly/__init__.py", line 192, in create
    await instance.initialize(True)
  File "/usr/local/lib/python3.8/site-packages/aioshelly/__init__.py", line 215, in initialize
    await event_d.wait()
  File "/usr/local/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/shelly/config_flow.py", line 91, in async_step_user
    device_info = await validate_input(self.hass, self.host, {})
  File "/config/custom_components/shelly/config_flow.py", line 42, in validate_input
    device = await aioshelly.Device.create(
  File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 55, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
mib1185 commented 3 years ago

is this already with "my" version with extended debug logging?

dodg3r commented 3 years ago

Yes. If I did it right :)

Hämta Outlook för iOShttps://aka.ms/o0ukef


Från: Michael @.> Skickat: Friday, March 19, 2021 10:12:31 PM Till: home-assistant/core @.> Kopia: Jerry Johansson @.>; Comment @.> Ämne: Re: [home-assistant/core] "Failed to connect" Shelly3em (#48122)

is this already with "my" version with extended debug logging?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fhome-assistant%2Fcore%2Fissues%2F48122%23issuecomment-803136304&data=04%7C01%7C%7C3db1752094fc4b42421c08d8eb1bb5a5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637517851527918833%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RpJgQ4zQUkG5vmNGA%2FONJseagQU26MGOrD7ApaqhJSo%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALCENE3S2WOP2VKA5PA6TQTTEO437ANCNFSM4ZPEE5YA&data=04%7C01%7C%7C3db1752094fc4b42421c08d8eb1bb5a5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637517851527928789%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=XFDdj9hp1Dz5M7ELw5AroBIAWQcI4X4%2F%2FRqyieP2kbM%3D&reserved=0.

mib1185 commented 3 years ago

There is a discussion on a shelly Facebook group ... https://m.facebook.com/groups/ShellyIoTCommunitySupport/permalink/3612421568857181 ... with a comment where a fix für 3em is supposed:

We found a issue with 3EM and integrations. Prepare a fix.

chemelli74 commented 3 years ago

We are working with Allterco to fix the issue related to latest 1.10 firmware. We'll keep you posted.

As a workaround, you can downgrade firmware.

Simone

dodg3r commented 3 years ago

Ok. Thanks

mfiaux commented 3 years ago

I'm having the same issue but not only with the Shelly EM, it is also happening with my Shelly Motion. I suspect it is related to the fact that the integration was deleted from HASS and when you try to add it again it will display the "Failed to connect" message. I did try to reset the Shelly back to factory default. When doing that it will discover the unit again, but it is unable to add it back, displaying "Failed to connect" again. Help is appreciated Mike

chemelli74 commented 3 years ago

I'm having the same issue but not only with the Shelly EM, it is also happening with my Shelly Motion.

Shelly Motion needs unicast config to work. Shelly EM should work with both config.

But please open new issues for those devices, if they don't work for you.

This thread is about 3EM

Simone

probot-home-assistant[bot] commented 3 years ago

Hey there @balloob, @bieniu, @thecode, mind taking a look at this issue as its been labeled with an integration (shelly) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

thecode commented 3 years ago

A new firmware released for Shelly 3EM which should solve this issue, I have validated that on my system it fixes the problem. Please update your device to latest version and test again. FW version 20210320-162133/v1.10.0-em3-g495c2e7

dodg3r commented 3 years ago

Yes, I can confirm that after firmware update and a reboot it works.

/Jerry

mfiaux commented 3 years ago

I confirm it worked for my Shelly3EM as well Thanks for the fix to all involved

chemelli74 commented 3 years ago

@doronazl, once confirmed by you please close this issue.

Simone

chemelli74 commented 3 years ago

@doronazl, do you mind update us ? Thank you in advance,

Simone

doronazl commented 3 years ago

yes the problem was on Shellys side, i reverted to older firmware and it worked the following day they released an updated firmware again which fixed this problem

thecode commented 3 years ago

@doronazl can you close this issue?