Don't use force_update for Tasmota sensors (#85943)
* fix: don't use force_update for Tasmota sensors * Update binary_sensor.py * Update test_binary_sensor.py * Update test_sensor.py --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>pull/90415/head
parent
0a51914740
commit
9fecdddf01
|
@ -58,17 +58,17 @@ class TasmotaBinarySensor(
|
|||
):
|
||||
"""Representation a Tasmota binary sensor."""
|
||||
|
||||
_attr_force_update = True
|
||||
_delay_listener: Callable | None = None
|
||||
_on_off_state: bool | None = None
|
||||
_tasmota_entity: tasmota_switch.TasmotaSwitch
|
||||
|
||||
def __init__(self, **kwds: Any) -> None:
|
||||
"""Initialize the Tasmota binary sensor."""
|
||||
self._delay_listener: Callable | None = None
|
||||
self._on_off_state: bool | None = None
|
||||
|
||||
super().__init__(
|
||||
**kwds,
|
||||
)
|
||||
if self._tasmota_entity.off_delay is not None:
|
||||
self._attr_force_update = True
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to MQTT events."""
|
||||
|
|
|
@ -268,7 +268,6 @@ async def async_setup_entry(
|
|||
class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, SensorEntity):
|
||||
"""Representation of a Tasmota sensor."""
|
||||
|
||||
_attr_force_update = True
|
||||
_tasmota_entity: tasmota_sensor.TasmotaSensor
|
||||
|
||||
def __init__(self, **kwds: Any) -> None:
|
||||
|
|
|
@ -106,7 +106,7 @@ async def test_controlling_state_via_mqtt(
|
|||
entity = hass.data["entity_components"]["binary_sensor"].get_entity(
|
||||
"binary_sensor.tasmota_binary_sensor_1"
|
||||
)
|
||||
assert entity.force_update
|
||||
assert not entity.force_update
|
||||
|
||||
|
||||
async def test_controlling_state_via_mqtt_switchname(
|
||||
|
|
|
@ -545,7 +545,7 @@ async def test_status_sensor_state_via_mqtt(
|
|||
entity = hass.data["entity_components"]["sensor"].get_entity(
|
||||
"sensor.tasmota_status"
|
||||
)
|
||||
assert entity.force_update
|
||||
assert not entity.force_update
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status_sensor_disabled", [False])
|
||||
|
|
Loading…
Reference in New Issue