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

Device Connection Error - Shelly devices after 2024.6.4 with Gen1 devices #120787

Closed mpartoglou closed 2 hours ago

mpartoglou commented 4 months ago

The problem

I recently upgraded to 2024.6.4 (I believe I might have missed 2024.6.3, but this issue was not present in 2024.6.0 and i believe it was fine .6.1). As part of this upgrade, I noticed that my Shelly Gen 1 devices (Shelly 1, Shelly Dimmers) are having intermittent connection issues - the same as was identified in this thread: https://github.com/home-assistant/core/issues/116975

I get all identical issues as per the previous thread where this was fixed:

Shelly device moves into a state where it becomes unresponsive in the front-end, but is still showing as active. The error is DeviceConnectionError Shelly device still operates and responds via hitting the Shelly device URL Shelly device, when hit via the URL directly still updates inside Home Assistant (i.e. I can receive new status updates) After some period of this, the Shelly devices go offline fully in Home Assistant and via URL I can force reconnect the devices (via Unifi) to start the cycle again

This issue is unique to Shelly Gen 1 devices as per before (my shelly gen 2 devices are once again rock solid).

Notes:

Shelly devices firmware: v1.14.0-gcb84623 Shelly devices us CoIoT connected via ip:port to HASS Shelly devices are all fixed IPs

I believe this is the same issue as previously where the Gen 1 devices are getting overwhelmed by too many requests (I know they only support two concurrent connections); then my unifi reconnect command resets this back to normal

What version of Home Assistant Core has the issue?

2024.6.4

What was the last working version of Home Assistant Core?

2024.6.0

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Shelly

Link to integration documentation on our website

https://www.home-assistant.io/integrations/shelly/

Diagnostics information

config_entry-shelly-445d0d281f721c56d3ad74de6dc6882e (1).json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-06-28 18:59:35.329 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140345294943520] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.86.148', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 311, in http_request
    resp: ClientResponse = await self.aiohttp_session.request(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.86.148:80 ssl:default [Connect call failed ('192.168.86.148', 80)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/shelly/entity.py", line 335, in set_state
    return await self.block.set_state(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 584, in set_state
    return await self.device.http_request("get", path, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 330, in http_request
    return await self.http_request(method, path, params, retry=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 335, in http_request
    raise DeviceConnectionError from err
aioshelly.exceptions.DeviceConnectionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1049, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 626, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/shelly/light.py", line 370, in async_turn_on
    self.control_result = await self.set_state(**params)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/shelly/entity.py", line 338, in set_state
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Setting state for entity Living room failed, state: {'turn': 'on', 'brightness': 40}, error: DeviceConnectionError()
2024-06-28 18:59:38.400 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140345294943520] Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.86.148', 80)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 311, in http_request
    resp: ClientResponse = await self.aiohttp_session.request(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.86.148:80 ssl:default [Connect call failed ('192.168.86.148', 80)]

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/shelly/entity.py", line 335, in set_state
    return await self.block.set_state(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 584, in set_state
    return await self.device.http_request("get", path, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 330, in http_request
    return await self.http_request(method, path, params, retry=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aioshelly/block_device/device.py", line 335, in http_request
    raise DeviceConnectionError from err
aioshelly.exceptions.DeviceConnectionError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1049, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 626, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/shelly/light.py", line 370, in async_turn_on
    self.control_result = await self.set_state(**params)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/shelly/entity.py", line 338, in set_state
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Setting state for entity Living room failed, state: {'turn': 'on', 'brightness': 39}, error: DeviceConnectionError()

Additional information

No response

home-assistant[bot] commented 4 months ago

Hey there @balloob, @bieniu, @thecode, @chemelli74, @bdraco, mind taking a look at this issue as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `shelly` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign shelly` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


shelly documentation shelly source (message by IssueLinks)

kebabuschi commented 4 months ago

Same here, but only with Shelly H&T. No problems with Shelly 1, 2.5 and Gas. 🤷‍♂️

jkoljo commented 4 months ago

Same here, but only with a certain Gen3 PM Mini. With 2024.6.2 there were zero issues. The data is intermittent and often unavailable. The device shows up ok in the shelly app. All other Shelly devices, including a few other Gen3 PM minis seem to behave better. They are all running the same fw. The PM mini in question reports good wifi, and it's quite close to an access point.

ranathan14 commented 4 months ago

Same problem here!!!

mpartoglou commented 4 months ago

Confirming the issue persists in 2024.7.0.

ranathan14 commented 4 months ago

2024-07-05 14:45:05.979 DEBUG (MainThread) [aioshelly.block_device.coap] Sending request 'cit/s' to device 192.168.1.244 2024-07-05 14:45:05.979 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: block device create, MAC: 34945469F8F4 2024-07-05 14:45:05.979 DEBUG (MainThread) [aioshelly.block_device.coap] Adding device 69F8F4 to CoAP message subscriptions 2024-07-05 14:45:05.980 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: block device initialize 2024-07-05 14:45:07.108 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: http request: /settings (params=None) 2024-07-05 14:45:08.294 DEBUG (MainThread) [aioshelly.block_device.device] aiohttp response: {'device': {'type': 'SHSW-25', 'mac': '34945469F8F4', 'hostname': 'shellyswitch25-34945469F8F4', 'num_outputs': 2, 'num_meters': 2, 'num_rollers': 1, 'mode': 'roller'}, 'wifi_ap': {'enabled': False, 'ssid': 'shellyswitch25-34945469F8F4', 'key': ''}, 'wifi_sta': {'enabled': True, 'ssid': 'TIM-44747932', 'ipv4_method': 'dhcp', 'ip': None, 'gw': None, 'mask': None, 'dns': None}, 'wifi_sta1': {'enabled': False, 'ssid': None, 'ipv4_method': 'dhcp', 'ip': None, 'gw': None, 'mask': None, 'dns': None}, 'ap_roaming': {'enabled': False, 'threshold': -70}, 'mqtt': {'enable': True, 'server': '192.168.1.10:1883', 'user': 'franieri', 'id': 'shelly_tapparella_cucina', 'reconnect_timeout_max': 60.0, 'reconnect_timeout_min': 2.0, 'clean_session': True, 'keep_alive': 60, 'max_qos': 0, 'retain': False, 'update_period': 30}, 'coiot': {'enabled': True, 'update_period': 15, 'peer': '192.168.1.10:5683'}, 'sntp': {'server': 'time.google.com', 'enabled': True}, 'login': {'enabled': False, 'unprotected': False, 'username': 'admin'}, 'pin_code': '', 'name': 'cucina', 'fw': '20230913-112234/v1.14.0-gcb84623', 'factory_reset_from_switch': True, 'pon_wifi_reset': False, 'discoverable': True, 'build_info': {'build_id': '20230913-112234/v1.14.0-gcb84623', 'build_timestamp': '2023-09-13T11:22:34Z', 'build_version': '1.0'}, 'cloud': {'enabled': False, 'connected': False}, 'timezone': 'Europe/Rome', 'lat': 41.112202, 'lng': 16.8547, 'tzautodetect': True, 'tz_utc_offset': 7200, 'tz_dst': False, 'tz_dst_auto': True, 'time': '14:45', 'unixtime': 1720183508, 'led_status_disable': False, 'debug_enable': False, 'allow_cross_origin': False, 'actions': {'active': False, 'names': ['btn_on_url', 'btn_off_url', 'longpush_url', 'shortpush_url', 'out_on_url', 'out_off_url', 'btn_on_url', 'btn_off_url', 'longpush_url', 'shortpush_url', 'out_on_url', 'out_off_url', 'roller_open_url', 'roller_close_url', 'roller_stop_url']}, 'hwinfo': {'hw_revision': 'prod-191217', 'batch_id': 1}, 'mode': 'roller', 'max_power': 1840, 'longpush_time': 800, 'relays': [{'name': None, 'appliance_type': 'General', 'ison': False, 'has_timer': False, 'default_state': 'switch', 'btn_type': 'toggle', 'btn_reverse': 0, 'auto_on': 0.0, 'auto_off': 0.0, 'max_power': 0, 'schedule': False, 'schedule_rules': []}, {'name': None, 'appliance_type': 'General', 'ison': False, 'has_timer': False, 'default_state': 'switch', 'btn_type': 'toggle', 'btn_reverse': 0, 'auto_on': 0.0, 'auto_off': 0.0, 'max_power': 0, 'schedule': False, 'schedule_rules': []}], 'rollers': [{'maxtime': 20.0, 'maxtime_open': 20.0, 'maxtime_close': 20.0, 'default_state': 'stop', 'swap': False, 'swap_inputs': False, 'input_mode': 'openclose', 'button_type': 'toggle', 'btn_reverse': 0, 'state': 'stop', 'power': 0.0, 'is_valid': True, 'safety_switch': False, 'schedule': False, 'schedule_rules': [], 'obstacle_mode': 'disabled', 'obstacle_action': 'stop', 'obstacle_power': 200, 'obstacle_delay': 1, 'ends_delay': 2500, 'safety_mode': 'while_opening', 'safety_action': 'stop', 'safety_allowed_on_trigger': 'none', 'off_power': 2, 'positioning': True}], 'favorites_enabled': False, 'favorites': [{'name': 'Position 1', 'pos': 0}, {'name': 'Position 2', 'pos': 0}, {'name': 'Position 3', 'pos': 0}, {'name': 'Position 4', 'pos': 0}], 'eco_mode_enabled': True} 2024-07-05 14:45:08.294 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: http request: /status (params=None) 2024-07-05 14:45:09.018 DEBUG (MainThread) [aioshelly.block_device.coap] CoapMessage: ip=192.168.1.244, type=CoapType.PERIODIC(30), options={11: b's', 3332: b'SHSW-25#34945469F8F4#2', 3412: b'\x96\x00', 3420: b'\x08\x00'}, payload={'G': [[0, 9103, 0], [0, 1102, 'stop'], [0, 1103, -1], [0, 2101, 0], [0, 2102, ''], [0, 2103, 0], [0, 2201, 0], [0, 2202, ''], [0, 2203, 0], [0, 4102, 0.0], [0, 4104, 198], [0, 6103, 'normal'], [0, 3104, 50.31], [0, 6101, 0], [0, 9101, 'roller'], [0, 4108, 233.95]]} 2024-07-05 14:45:09.018 DEBUG (MainThread) [aioshelly.block_device.coap] Calling CoAP message update for device id 69F8F4 2024-07-05 14:45:09.372 DEBUG (MainThread) [aioshelly.block_device.device] aiohttp response: {'wifi_sta': {'connected': True, 'ssid': 'TIM-44747932', 'ip': '192.168.1.244', 'rssi': -55}, 'cloud': {'enabled': False, 'connected': False}, 'mqtt': {'connected': False}, 'time': '14:45', 'unixtime': 1720183510, 'serial': 8, 'has_update': False, 'mac': '34945469F8F4', 'cfg_changed_cnt': 0, 'actions_stats': {'skipped': 0}, 'rollers': [{'state': 'stop', 'source': 'http', 'power': 0.0, 'is_valid': True, 'safety_switch': False, 'overtemperature': False, 'stop_reason': 'normal', 'last_direction': 'open', 'current_pos': 101, 'calibrating': False, 'positioning': True}], 'meters': [{'power': 0.0, 'overpower': 0.0, 'is_valid': True, 'timestamp': 1720190710, 'counters': [0.0, 0.0, 0.0], 'total': 15}, {'power': 0.0, 'overpower': 0.0, 'is_valid': True, 'timestamp': 1720190710, 'counters': [0.0, 0.0, 0.0], 'total': 183}], 'inputs': [{'input': 0, 'event': '', 'event_cnt': 0}, {'input': 0, 'event': '', 'event_cnt': 0}], 'temperature': 50.31, 'overtemperature': False, 'tmp': {'tC': 50.31, 'tF': 122.56, 'is_valid': True}, 'temperature_status': 'Normal', 'update': {'status': 'idle', 'has_update': False, 'new_version': '20230913-112234/v1.14.0-gcb84623', 'old_version': '20230913-112234/v1.14.0-gcb84623', 'beta_version': '20231107-163214/v1.14.1-rc1-g0617c15'}, 'ram_total': 50720, 'ram_free': 36632, 'fs_size': 233681, 'fs_free': 145831, 'voltage': 233.95, 'uptime': 10885} 2024-07-05 14:45:09.372 DEBUG (MainThread) [aioshelly.block_device.coap] Sending request 'cit/d' to device 192.168.1.244 2024-07-05 14:45:17.109 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: error: DeviceConnectionError(TimeoutError()) 2024-07-05 14:45:17.109 DEBUG (MainThread) [aioshelly.block_device.device] host 192.168.1.244: block device shutdown

mpartoglou commented 4 months ago

Unsure if coincidence or otherwise but since updating to 2024.7.1 I haven’t had any issues (will report back if this changes.

danstreeter commented 4 months ago

I was suffering this issue also but not all Gen1 devices at once, I upgraded from 2024.6.4 to 2024.7.1 to try and alleviate with no joy, however after reading the docs again for any breaking changes or incompatibilities - seems that somewhere (that I at least did not notice) there was a need to shift over Gen1 devices from using multicast CoIoT to unicast with a specific IP and Port. (As I was doing them they were all set to mcast).

Generation 1 devices use the CoIoT protocol to communicate with the integration. CoIoT must be enabled in the device settings. Navigate to the local IP address of your Shelly device, Internet & Security > ADVANCED - DEVELOPER SETTINGS and check the box Enable CoIoT.

We recommend using unicast for communication. To enable this, enter the local IP address of the Home Assistant server and port 5683 into the CoIoT peer field and push SAVE button. This is mandatory for battery operated devices (even if USB connected). After changing the CoIoT peer, the Shelly device needs to be manually restarted.

Ref here: https://www.home-assistant.io/integrations/shelly

After updating all my Gen1 devices to use unicast of my Home Assistant node with port 5683 as stated - they all worked fine.

UPDATE: This said, and where the integration config entries state that the device is connecting ok - I cannot control it via Home Assistant. The state is updated of the switch entity (for Gen1 Shelly 1 & also 2.5's) when the physical switch is switched, however I cannot turn it on/off via Home Assistant anymore.

mpartoglou commented 4 months ago

Hi @danstreeter ,

confirming that my setup is using the COIOT protocol as per your comment in the breaking changes. For me this also guaranteed that the Shelly Unit was talking to my HASS service (and extremely reliably), but I also have the same issue of HASS not talking to my Shelly Units.

image

For no particular reason mine has been stable for a few days on 2024.7.1

ranathan14 commented 4 months ago

If it can be of help, I would like to point out the following. I solved the issue by adding the device with an old version of Home Assistant 2026.4.1. Only at that point was the Shelly 2.5 automatically re-added simply upon reboot. After adding it, I updated to the latest version and it seems to be working. It appears that the latest versions have some problems during the new configuration phase of the device.

flyingbrike commented 4 months ago

I have 1 Shello Pro4pm running fine with colot . But 1 shelly adc keeps changing his ipadres. I configured a fixed ip, but that data is reset every x amount of time. Maybe device malfuncion

jbeckerwsi commented 4 months ago

I see the same behavior as reported by @danstreeter, the devices report state back to HA, but I cannot control them.

I have 3 Shelly TRV running firmware version 20240619-130912/v2.2.4@ee290818 running with CoIoT (fixed peer) Homeassistant version 2024.7.2

2024-07-13 09:10:46.251 DEBUG (MainThread) [aioshelly.common] host 10.0.20.17:80: error: DeviceConnectionError(TimeoutError())
2024-07-13 09:10:46.252 DEBUG (MainThread) [aioshelly.block_device.device] host 10.0.20.17: error: DeviceConnectionError(DeviceConnectionError(TimeoutError()))
2024-07-13 09:10:46.252 ERROR (MainThread) [homeassistant.components.shelly] Error connecting to Shelly device shellytrv-60A423D91C66, error: DeviceConnectionError(DeviceConnectionError(TimeoutError()))

Every now an again it actually works to control the device.

The latency to the device seems quite high to me. Maybe increasing the timeout and/or adding one or two retries can help? (edit: it looks like it is already doing that https://github.com/home-assistant-libs/aioshelly/blob/a07ead7206a82067cecda0334feeb34f9cd990f0/aioshelly/block_device/device.py#L314C25-L314C42 )

ping 10.0.20.17
PING 10.0.20.17 (10.0.20.17): 56 data bytes
64 bytes from 10.0.20.17: icmp_seq=0 ttl=254 time=90.696 ms
Request timeout for icmp_seq 1
64 bytes from 10.0.20.17: icmp_seq=1 ttl=254 time=1168.199 ms
64 bytes from 10.0.20.17: icmp_seq=2 ttl=254 time=168.275 ms
64 bytes from 10.0.20.17: icmp_seq=3 ttl=254 time=318.678 ms
64 bytes from 10.0.20.17: icmp_seq=4 ttl=254 time=1893.700 ms
64 bytes from 10.0.20.17: icmp_seq=5 ttl=254 time=893.189 ms
Request timeout for icmp_seq 7
64 bytes from 10.0.20.17: icmp_seq=6 ttl=254 time=2257.171 ms
64 bytes from 10.0.20.17: icmp_seq=7 ttl=254 time=2397.987 ms
64 bytes from 10.0.20.17: icmp_seq=8 ttl=254 time=1397.390 ms
64 bytes from 10.0.20.17: icmp_seq=9 ttl=254 time=396.683 ms
64 bytes from 10.0.20.17: icmp_seq=10 ttl=254 time=801.953 ms
^C
--- 10.0.20.17 ping statistics ---
12 packets transmitted, 11 packets received, 8.3% packet loss
round-trip min/avg/max/stddev = 90.696/1071.266/2397.987/789.782 ms
danstreeter commented 4 months ago

Morning all. I thought I was onto something but alas - no joy.

Upgraded one of my Gen1 Shelly1's which is having this issue to BETA firmware version 20231107-162940/v1.14.1-rc1-g0617c15 (from 20230913-112003/v1.14.0-gcb84623) and I could control it via Home Assistant - for a moment. Then it returned to its DeviceConnectionError state again.

@ranathan14 - I upgraded from 2024.6.4 with all my Shelly devices already part of the install, then they broke rather than adding them straight into the new version. To further test a theory I removed one of my existing devices that this issue is occuring on, but am now unable to add it again. :( So that one is dead to me now unable to get it back into HASS.

jkoljo commented 4 months ago

Not absolutely sure if this is related, but I started having connectivity issues with my gen3 mini devices after 2024.6.4. I switched their powersave feature off a few days ago, and they have been stable after that.

webjester0 commented 4 months ago

I have a similar issue. I get duplicate devices for the same phone. One with 97 Entities, one with 98. I disabled the one with 97 entries. But magically it enabled itself again.

image

thecode commented 4 months ago

@webjester0 please create a new issue, your issue is not related to this issue.

LeoH1310 commented 4 months ago

I'm running Core 2024.7.2 and had the same issue that I could not add my shelly TVRs. I enabled CoIoT as described here: https://www.home-assistant.io/integrations/shelly/#shelly-device-configuration-generation-1 After that the TVRs did not show up automatically but I was able to add them manually by its IP. Not sure if that's the issue here but it worked for me so maybe that helps someone else.

GermanCaruncho commented 3 months ago

Since yesterday's update 2024.8 it no longer connects. In the previous ones, after restarting and disconnecting switches, it occasionally connected and stayed for days.

2024-08-08 19:46:13.356 DEBUG (MainThread) [aioshelly.rpc_device.device] host 192.168.1.103:80: error: DeviceConnectionError(RpcCallError(404, 'No handler for Shelly.GetComponents'))

thecode commented 3 months ago

Since yesterday's update 2024.8 it no longer connects. In the previous ones, after restarting and disconnecting switches, it occasionally connected and stayed for days.

2024-08-08 19:46:13.356 DEBUG (MainThread) [aioshelly.rpc_device.device] host 192.168.1.103:80: error: DeviceConnectionError(RpcCallError(404, 'No handler for Shelly.GetComponents'))

This is a different issue, please create a new issue with diagnostics if you want your issue to be fixed

issue-triage-workflows[bot] commented 1 week ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.