Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to unload devices not present anymore in the bus #109

Open
11ange opened this issue Mar 28, 2021 · 1 comment
Open

How to unload devices not present anymore in the bus #109

11ange opened this issue Mar 28, 2021 · 1 comment

Comments

@11ange
Copy link

11ange commented Mar 28, 2021

Hello !
How I can unload ou remove devices that are no present anymore in the bus? Everytime I connect a sensor on the bus a new folder is created (at /sys/bus/w1/devices/w1_bus_master1 with the HW-ID of the new sensor), but folders for defective sensors or sensors not present are still there.

Here is part of my code:

sensores = W1ThermSensor.get_available_sensors()
if len(sensores) == 2:
    try:
        sensor1 = W1ThermSensor(Sensor.DS18B20, sensores[0].id)
        dicio_ds["ds0"] = format(sensor1.get_temperature(), "^4.1f")
    except SensorNotReadyError:
        dicio_ds["ds0"] = -126
    try:
        sensor2 = W1ThermSensor(Sensor.DS18B20, sensores[1].id)
        dicio_ds["ds1"] = format(sensor2.get_temperature(), "^4.1f")
    except SensorNotReadyError:
        dicio_ds["ds1"] = -126
else:
    dicio_ds["ds0"] = -126
    dicio_ds["ds1"] = -126

If one of the sensors are defective and I remove it and put a new one, the len(sensores)=3 and it is not desirable, as I have only 2 sensors operational.
Is this possible or should I improve my code?
Thank you in advance!

@bsimmo
Copy link

bsimmo commented Sep 12, 2021

Can you trigger a refresh sensors ? It could be built into an faulty sensor check too.
The ghost/removed sensors would report a faulty code or missing measurement. So trigger a check (button/command/timed and have them removed from your dicio_ds
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants