Skip to content

Error when DS18B20 temperature sensor is disconnected #237

Description

@glynhudson

emonHub displays the following error when a DS18B20 temperature sensor is disconnected:

2026-08-10 14:23:51,013 WARNING  DS18B20    Exception caught in DS18B20 thread. Traceback (most recent call last):
  File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 31, in wrapper
    return func(*args)
           ^^^^^^^^^^^
  File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 105, in run
    rxc = self.read()
          ^^^^^^^^^^^
  File "/opt/openenergymonitor/emonhub/src/interfacers/EmonHubDS18B20Interfacer.py", line 110, in read
    value = self.ds.tempC(sensor)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/openenergymonitor/emonhub/src/interfacers/EmonHubDS18B20Interfacer.py", line 42, in tempC
    if len(lines[0]):
           ~~~~~^^^
IndexError: list index out of range

EmonHub should gracefully trying to read from a temperature sensor when it's been disconnected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions