StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
615 stars 110 forks source link

[BUG] shelly for hass is flooding the log with errors #678

Open peterus opened 2 years ago

peterus commented 2 years ago

Environment

Describe the bug

2022-05-28 21:57:42 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform shelly
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 548, in _async_add_entity
    entity.add_to_platform_abort()
  File "/config/custom_components/shelly/block.py", line 49, in add_to_platform_abort
    super().add_to_platform_abort()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 800, in add_to_platform_abort
    self._call_on_remove_callbacks()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 793, in _call_on_remove_callbacks
    self._on_remove.pop()()
  File "/config/custom_components/shelly/block.py", line 59, in _remove_handler
    self._block.cb_updated.remove(self._updated)
ValueError: list.remove(x): x not in list
2022-05-28 21:57:42 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 548, in _async_add_entity
    entity.add_to_platform_abort()
  File "/config/custom_components/shelly/block.py", line 49, in add_to_platform_abort
    super().add_to_platform_abort()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 800, in add_to_platform_abort
    self._call_on_remove_callbacks()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 793, in _call_on_remove_callbacks
    self._on_remove.pop()()
  File "/config/custom_components/shelly/block.py", line 59, in _remove_handler
    self._block.cb_updated.remove(self._updated)
ValueError: list.remove(x): x not in list

Steps to Reproduce

not very sure where this error message is coming from. It is just flooding the logs

Expected behavior

no error msg.

Screenshots

Traceback/Error logs

Additional context

bcutter commented 1 year ago

Definitely option B, with a final full reboot

OK, thank you for confirmation @Stewie3112. I fear removing the integration cause it "feels" like deleting all devices, entities and corresponding history (which would be a total desaster). But that's not the case, right?

So deleting the integration is "safe" and step number one, right?

grafik

Stewie3112 commented 1 year ago

Of course you'll loose devices and entities related to shellyforhass integration. As I wrote before you must take some time to write down all the relevant ones to restore them later. I used an excel workbook with device name, entity ids, icons, etc...

As automations and custom configurations refer to the entity id you'll have only to restore them later to the new entities added with the official integration, overriding the default one.

bcutter commented 1 year ago

I know entity_id's are important here. I was just thinking that removing (deleting) an integration always deletes all corresponding devices and entities from the database completely, so there's no history anymore.

That seems not to be the case, instead those records will stay in the database so once there are new entities matched to that still existing entity_id's, their history will continue - almost as they've never been away.

Good default behaviour of HA, great for switching integrations. It's just that "remove" and "delete" don't implicate that "we'll just hide that data from the frontend, everything is still there in the backend/database!" behavior so asking twice before loosing everything was a good idea in my opinion ;-)


Update: Migration finished.

Summary: I see absolutely no reasons for staying with the custom Shelly integration - except fearing the migration work itself maybe. It hurts once a bit depending on the amount of devices - but resolves so many (unresolved) issues and feels just good to drive the default highway now.

dwarfer166 commented 1 year ago

+1 for following this process. I have 12 Shelly devices and managed to switch them all over following the process detailed above.

One point worth noting is if the Shelly device isn't named (on the web interface of the Shelly) then it will show in Home Assistant using the MAC address as its name within the Shelly integration which is less than ideal when you want to find a particular one.

To resolve this, I had to ensure that the Device Name was completed on the Shellys. Although even then I had two Shellys that still showed a MAC (these are newer devices so I am guessing slightly different hardware/firmware versions). For these ones, I then tested filling in the Channel Name as well and, hey presto, all the names showed in HA fine.

TL;DR: Complete the Device Name and Channel Name on your Shelly devices via the web interface before adding them to HA.

image

image