Handle None when trucating long Environment Canada state values (#29208)

* Handle None when trucating long state values, add info message

* Black
This commit is contained in:
michaeldavie 2019-11-28 22:13:21 -05:00 committed by Martin Hjelmare
parent 1c824f5ca7
commit 1322661ee0

View File

@ -134,8 +134,11 @@ class ECSensor(Entity):
)
elif self.sensor_type == "tendency":
self._state = str(value).capitalize()
else:
elif value is not None and len(value) > 255:
self._state = value[:255]
_LOGGER.info("Value for %s truncated to 255 characters", self._unique_id)
else:
self._state = value
if sensor_data.get("unit") == "C" or self.sensor_type in [
"wind_chill",