ESPHome fix missing state in certain circumstances (#28729)
* Fix ESPHome having missing state in certain situations Fixes https://github.com/esphome/issues/issues/828 * Update requirements_all * Also fix climate preset mode
This commit is contained in:
parent
fc04b3e31c
commit
a1f2b6d402
6 changed files with 10 additions and 4 deletions
|
@ -67,6 +67,8 @@ class EsphomeSensor(EsphomeEntity):
|
|||
"""Return the state of the entity."""
|
||||
if math.isnan(self._state.state):
|
||||
return None
|
||||
if self._state.missing_state:
|
||||
return None
|
||||
return "{:.{prec}f}".format(
|
||||
self._state.state, prec=self._static_info.accuracy_decimals
|
||||
)
|
||||
|
@ -96,4 +98,6 @@ class EsphomeTextSensor(EsphomeEntity):
|
|||
@esphome_state_property
|
||||
def state(self) -> Optional[str]:
|
||||
"""Return the state of the entity."""
|
||||
if self._state.missing_state:
|
||||
return None
|
||||
return self._state.state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue