1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00

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>
This commit is contained in:
DerEnderKeks 2023-03-28 17:14:52 +02:00 committed by GitHub
parent 0a51914740
commit 9fecdddf01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 7 deletions

View File

@ -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."""

View File

@ -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:

View File

@ -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(

View File

@ -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])