DHT Catch KeyError#9096
Closed
ulf-de wants to merge 1 commit into
Closed
Conversation
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.
balloob
reviewed
Aug 23, 2017
| temperature = data[SENSOR_TEMPERATURE] | ||
| except KeyError: | ||
| _LOGGER.error("Error reading temperature data") | ||
| return |
Member
There was a problem hiding this comment.
This breaks the situation when the returned data contains humidity data but no temperature data.
Contributor
|
Already fixed by #9198 |
Contributor
Author
|
The fix #9198 is slightly different as it always expects the sensor to returns both values. Most likely it will always return both values. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
During the start of homeassistant the DHT sensor sometimes does not return data.
Error message:
This patch will log the error and exit the function. During the next run the sensor is ready to deliver the data.