mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 04:41:30 -04:00
Drop the redundant Sofar total sensor seed (#185966)
This commit is contained in:
@@ -138,8 +138,6 @@ class SofarTotalSensor(SofarEntity, RestoreSensor):
|
||||
except ValueError, TypeError:
|
||||
return
|
||||
self._attr_native_value = val
|
||||
if (total_fn := self.entity_description.total_fn) is not None:
|
||||
total_fn(self.coordinator.device).seed(val)
|
||||
|
||||
@property
|
||||
@override
|
||||
|
||||
@@ -302,32 +302,6 @@ async def test_total_sensor_restore_data_parsing(
|
||||
assert unset_sensor.native_value is None
|
||||
|
||||
|
||||
async def test_total_sensor_seeds_high_water_from_restored_value(
|
||||
hass: HomeAssistant, init_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test a restored value seeds the library's high-water mark."""
|
||||
runtime_data = init_integration.runtime_data
|
||||
device = runtime_data.readings.device
|
||||
description = SofarSensorDescription(
|
||||
key="load_consumption_total",
|
||||
component="meter_energy",
|
||||
translation_key="load_consumption_total",
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
value_fn=lambda device: (
|
||||
device.meter_energy.load_consumption_total_corrected.value
|
||||
),
|
||||
total_fn=lambda device: device.meter_energy.load_consumption_total_corrected,
|
||||
)
|
||||
sensor = SofarTotalSensor(runtime_data, description)
|
||||
sensor.hass = hass
|
||||
sensor.async_get_last_sensor_data = AsyncMock(
|
||||
return_value=SimpleNamespace(native_value="555.5")
|
||||
)
|
||||
with patch.object(device.meter_energy, "seed_high_water") as mock_seed:
|
||||
await sensor.async_added_to_hass()
|
||||
mock_seed.assert_called_once_with("load_consumption_total", 555.5)
|
||||
|
||||
|
||||
async def test_sensor_dead_link_unavailable(init_integration: MockConfigEntry) -> None:
|
||||
"""Test SofarSensor.available is False when the last update failed."""
|
||||
runtime_data = init_integration.runtime_data
|
||||
|
||||
Reference in New Issue
Block a user