diff --git a/homeassistant/components/tasmota/sensor.py b/homeassistant/components/tasmota/sensor.py index 17a6e2a35c2..39577e9e558 100644 --- a/homeassistant/components/tasmota/sensor.py +++ b/homeassistant/components/tasmota/sensor.py @@ -192,6 +192,11 @@ class TasmotaSensor(TasmotaAvailability, TasmotaDiscoveryUpdate, Entity): return self._state.isoformat() return self._state + @property + def force_update(self): + """Force update.""" + return True + @property def unit_of_measurement(self): """Return the unit this state is expressed in.""" diff --git a/tests/components/tasmota/test_binary_sensor.py b/tests/components/tasmota/test_binary_sensor.py index 6d4263853dc..6b13dcc89ec 100644 --- a/tests/components/tasmota/test_binary_sensor.py +++ b/tests/components/tasmota/test_binary_sensor.py @@ -95,6 +95,12 @@ async def test_controlling_state_via_mqtt(hass, mqtt_mock, setup_tasmota): state = hass.states.get("binary_sensor.tasmota_binary_sensor_1") assert state.state == STATE_OFF + # Test force update flag + entity = hass.data["entity_components"]["binary_sensor"].get_entity( + "binary_sensor.tasmota_binary_sensor_1" + ) + assert entity.force_update + async def test_controlling_state_via_mqtt_switchname(hass, mqtt_mock, setup_tasmota): """Test state update via MQTT.""" diff --git a/tests/components/tasmota/test_sensor.py b/tests/components/tasmota/test_sensor.py index fe415c264ef..6e5160273d6 100644 --- a/tests/components/tasmota/test_sensor.py +++ b/tests/components/tasmota/test_sensor.py @@ -275,6 +275,12 @@ async def test_status_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota): state = hass.states.get("sensor.tasmota_status") assert state.state == "20.0" + # Test force update flag + entity = hass.data["entity_components"]["sensor"].get_entity( + "sensor.tasmota_status" + ) + assert entity.force_update + @pytest.mark.parametrize("status_sensor_disabled", [False]) async def test_single_shot_status_sensor_state_via_mqtt(hass, mqtt_mock, setup_tasmota):