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
|
@ -44,6 +44,8 @@ class EsphomeBinarySensor(EsphomeEntity, BinarySensorDevice):
|
|||
return self._entry_data.available
|
||||
if self._state is None:
|
||||
return None
|
||||
if self._state.missing_state:
|
||||
return None
|
||||
return self._state.state
|
||||
|
||||
@property
|
||||
|
|
|
@ -138,7 +138,7 @@ class EsphomeClimateDevice(EsphomeEntity, ClimateDevice):
|
|||
@esphome_state_property
|
||||
def preset_mode(self):
|
||||
"""Return current preset mode."""
|
||||
return PRESET_AWAY if self._state.away else None
|
||||
return PRESET_AWAY if self._state.away else PRESET_HOME
|
||||
|
||||
@esphome_state_property
|
||||
def current_temperature(self) -> Optional[float]:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||
"requirements": [
|
||||
"aioesphomeapi==2.4.2"
|
||||
"aioesphomeapi==2.5.0"
|
||||
],
|
||||
"dependencies": [],
|
||||
"zeroconf": ["_esphomelib._tcp.local."],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -142,7 +142,7 @@ aiobotocore==0.10.2
|
|||
aiodns==2.0.0
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==2.4.2
|
||||
aioesphomeapi==2.5.0
|
||||
|
||||
# homeassistant.components.freebox
|
||||
aiofreepybox==0.0.8
|
||||
|
|
|
@ -50,7 +50,7 @@ aioautomatic==0.6.5
|
|||
aiobotocore==0.10.2
|
||||
|
||||
# homeassistant.components.esphome
|
||||
aioesphomeapi==2.4.2
|
||||
aioesphomeapi==2.5.0
|
||||
|
||||
# homeassistant.components.emulated_hue
|
||||
# homeassistant.components.http
|
||||
|
|
Loading…
Add table
Reference in a new issue