Odd 1-wire temperature sensor behavior - unavailable in dashboard when it seems to be working fine

I had to set up my pi back up from scratch due to SD card failure. Now that I’ve done so and hooked it back up to my 1-wire temperature sensors I’m seeing a new behavior that I never saw when first setting those sensors up. One of the sensors is listed as ‘unavailable’ even across pi reboots / hass restarts. However unlike all my previous experiences, it’s still showing as a device in the raw file system and updating the temperate regularly. The device ID is correct so I don’t know why it’s showing as unavailable in home assistant. What other requirements are necessary for a sensor to be seen as present for home assistant?

Well, in further observation I saw that the timestamp on /sys/bus/w1/device//temperature wasn’t changing the way all the other sensor devices was. I swapped out the sensor (it was still one of the ‘bad’ cheap ones I bought off amazon) with a good ‘cheap’ one. And that fixed it. Then I saw I had another one had started exhibiting the same behavior. That was also old so I swapped that out but this time the new sensor didn’t help.

It could be that the misbehaving devices aren’t disappearing for the file system the way I used to see because the replacement pi is a pi4 running buster (old was a pi3b+ running stretch) and since I’ve reinstalled everything I probably have a newer home assistant (and it’s now running in docker). So a lot changed between the old and new setup.

But one thing that still bugs the heck out of me is the stupid ‘xx minutes ago’ text on home assistant that seems to have no relation to anything I can discern about the sensors in the file system. And it certainly doesn’t match when the last sensor value was written and/or read by home assistant. It’s happily updating to newer values without that ‘xx minutes ago’ text refreshing back to zero. I used to think that was the last time the sensor value changed (so it was really ‘last changed xx minutes ago’) but in the investigation just now I saw that the value had changed, home assistant had picked the new raw value up, but the UI still had the old ‘xx minutes ago’ text.

Ok, weirder and weirder. I see that:
Had an up to date timestamp (5:17pm). And the value has changed.
Has a stale timestamp (from when I restarted the pi) and now has the same temperature value.

Keeping an eye on this I see that the timestamp still hasn’t changed but the temperature value has again. And looking at other similar directories, they also have less than current timestamps on that temp1_input file. But home assistant isn’t having any issues with them and has the latest correct raw value for them.

Home assistant is still refusing to acknowledge the one sensor exists but as far as I can tell it’s behaving exactly like every other sensor.

So my theory because that trying to editor the sensor ID in place in the lovelace UI (so it got the same friendly name) somehow inherited the ‘unavailable’ state of the old sensor in a way that persisted across restarts of hass/reboots of the pi. So I removed the sensor via the UI, couldn’t find a way to find a list of removed sensors to re-add it, so just rebooted. And it was then available as a sensor so I was able to add it back to the dashboard and give it a friendly name. Great! …

… except now one of my other sensors is doing the same thing - listed as unavailable in the dashboard but present as a device in the file system and seemingly working fine. What the heck is going on!?

… and I restarted the hass container again and it flipped back to the previous temperature sensor being listed as unavailable. Both are still reporting values correctly in the file system as best I can tell.

And a different one again on another pi reboot. I see these log entries:

Update for sensor.28_01193f1ca2c4_temperature fails

6:17:11 PM – components/onewire/sensor.py (ERROR) - message first occurred at 6:14:41 PM and shows up 6 times

Setup of sensor platform onewire is taking over 10 seconds.

6:13:05 PM – Sensor (WARNING)

onewire: Error on device update!

6:12:58 PM – Sensor (ERROR)

The listed sensor isn’t the one that’s currently unavailable. It might have been the same id that was listed last reboot in the logs though. Maybe that sensor is slowing things down and causing home assistant to time out it’s one-wire enumeration somehow?