Fix track_change error in utility_meter (#21134)

* split validation

* remove any()
This commit is contained in:
Diogo Gomes 2019-02-18 04:40:51 +00:00 committed by Paulus Schoutsen
parent ce7f678b9b
commit 3b5ed7a20f

View File

@ -83,9 +83,9 @@ class UtilityMeterSensor(RestoreEntity):
@callback
def async_reading(self, entity, old_state, new_state):
"""Handle the sensor state changes."""
if any([old_state is None,
old_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE],
new_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE]]):
if old_state is None or new_state is None or\
old_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE] or\
new_state.state in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
return
if self._unit_of_measurement is None and\