core: 1-wire device on RPi cannot be removed

The problem

After physically removing/disconnecting 1-wire temperature sensor (DS18B20) from RPi4 the device is still in the Integration page. I do not use configuration.yaml for 1-wire integration. After removing the sensor I have several time restarted and rebooted my instance and this did not help. Still when I go to Configuration/Integrations I see 4 devices and 3 entities. When I click on “4 devices” I get the list and the one which is removed can only be disabled. I am not able to remove/delete it. It should be possible to delete this device.

What is version of Home Assistant Core has the issue?

core-2021.3.0 - but also previous ones have it

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

1-Wire

Link to integration documentation on our website

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

Example YAML snippet

There is no entry in configuration.yaml for this integration

Anything in the logs that might be useful for us?

# Put your logs below this line

Logger: homeassistant.components.onewire.sensor Source: components/onewire/sensor.py:430 Integration: 1-Wire (documentation, issues) First occurred: 4 March 2021, 15:54:45 (18 occurrences) Last logged: 09:49:16

Cannot read from sensor /sys/bus/w1/devices/28-3c01a8168f7a/w1_slave: Unsupport response [] Cannot read from sensor /sys/bus/w1/devices/28-0000049212b9/w1_slave: Unsupport response [] Cannot read from sensor /sys/bus/w1/devices/28-00000492032b/w1_slave: Unsupport response []

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (14 by maintainers)

Commits related to this issue

Most upvoted comments

But for 1-wire we have no way to know if the device is missing purposefully (removed) or temporarily/accidently (device failure or wiring issue) so I don’t want to implement automatic cleanup of entities. In my opinion it is better to have them unavailable (to be deleted manually) than disappearing unexpectedly.

For devices, there is definitely a case for automatic cleanup if there are no attached entities. Possibly with a code similar to this one (extracted from deconz):

    # Get registries
    device_registry, entity_registry = await asyncio.gather(
        hass.helpers.device_registry.async_get_registry(),
        hass.helpers.entity_registry.async_get_registry(),
    )

    # Generate list of all device entries
    devices_to_be_removed = [
        entry.id
        for entry in device_registry.devices.values()
    ]

    # Remove devices that don't belong to any entity
    for device_id in devices_to_be_removed:
        if (
            len(
                async_entries_for_device(
                    entity_registry, device_id, include_disabled_entities=True
                )
            )
            == 0
        ):
            device_registry.async_remove_device(device_id)

Then the last question becomes: where is it best to place this code?

  • In a service (to be run manually)?
  • When an entity is removed?
  • During the initialisation process (gets triggered on restart)?

It seems zwave_js integration has it implemented on restart - but it’s also a complicated place as need to ensure the platforms have been fully initialised and also that server isn’t attempting to stop…

@epenet - I very much appreciate and fully support your approach !

But for 1-wire we have no way to know if the device is missing purposefully (removed) or temporarily/accidently (device failure or wiring issue) so I don’t want to implement automatic cleanup of entities. In my opinion it is better to have them unavailable (to be deleted manually) than disappearing unexpectedly.

Exactly, it may happen that wire to your sensor gets disconnected (or cut) in which case you do not want the device and entity to be removed. I would expect some sort of notification which in a way today exist in the form of WARNING in the log (maybe from user prospective it would be “nicer” to have more specific indication ? (There might be several warnings which not always gets proper attention) to give to user.

So, I would also support @Misiu to open possibility to delete device but not remove it “automatically”.

@frenck

Either contribute it, or leave this issue open as a bug report that someone could pick up 🤷

I am afraid I do not have enough knowledge to “contribute” so at this point of time I would leave it as bug report… Thanks.