Skip to content

DHT Catch KeyError#9096

Closed
ulf-de wants to merge 1 commit into
home-assistant:devfrom
ulf-de:patch-3
Closed

DHT Catch KeyError#9096
ulf-de wants to merge 1 commit into
home-assistant:devfrom
ulf-de:patch-3

Conversation

@ulf-de
Copy link
Copy Markdown
Contributor

@ulf-de ulf-de commented Aug 22, 2017

Description:

During the start of homeassistant the DHT sensor sometimes does not return data.
Error message:

  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/dht.py", line 139, in update
    humidity = data[SENSOR_HUMIDITY]
KeyError: 'humidity'

This patch will log the error and exit the function. During the next run the sensor is ready to deliver the data.

During the start of homeassistant the DHT sensor sometimes does not return data.
Error message:
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/dht.py", line 139, in update
    humidity = data[SENSOR_HUMIDITY]
KeyError: 'humidity'

This patch will log the error and exit the function. During the next run the sensor is ready to deliver the data.
temperature = data[SENSOR_TEMPERATURE]
except KeyError:
_LOGGER.error("Error reading temperature data")
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the situation when the returned data contains humidity data but no temperature data.

@andrey-git
Copy link
Copy Markdown
Contributor

Already fixed by #9198

@ulf-de
Copy link
Copy Markdown
Contributor Author

ulf-de commented Aug 29, 2017

The fix #9198 is slightly different as it always expects the sensor to returns both values. Most likely it will always return both values.
I close the PR

@ulf-de ulf-de closed this Aug 29, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants