From b44de9cbded7b8ee2c91c246e7e053f770e3fc30 Mon Sep 17 00:00:00 2001 From: Takayuki Date: Sun, 27 Sep 2026 14:05:46 +0900 Subject: [PATCH] Bump momonga to 0.7.0 (#183254) Co-authored-by: Claude Opus 5.5 --- .../route_b_smart_meter/coordinator.py | 8 ++--- .../route_b_smart_meter/manifest.json | 2 +- requirements_all.txt | 2 +- .../route_b_smart_meter/test_sensor.py | 33 ++++++++++++++++++- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/route_b_smart_meter/coordinator.py b/homeassistant/components/route_b_smart_meter/coordinator.py index 72bd13c4909e..f0b406965824 100644 --- a/homeassistant/components/route_b_smart_meter/coordinator.py +++ b/homeassistant/components/route_b_smart_meter/coordinator.py @@ -21,10 +21,10 @@ _LOGGER = logging.getLogger(__name__) class BRouteData: """Class for data of the B Route.""" - instantaneous_current_r_phase: float - instantaneous_current_t_phase: float - instantaneous_power: float - total_consumption: float + instantaneous_current_r_phase: float | None + instantaneous_current_t_phase: float | None + instantaneous_power: float | None + total_consumption: float | None type BRouteConfigEntry = ConfigEntry[BRouteUpdateCoordinator] diff --git a/homeassistant/components/route_b_smart_meter/manifest.json b/homeassistant/components/route_b_smart_meter/manifest.json index 36ff3ed6a209..5138e3aade32 100644 --- a/homeassistant/components/route_b_smart_meter/manifest.json +++ b/homeassistant/components/route_b_smart_meter/manifest.json @@ -13,5 +13,5 @@ "momonga.sk_wrapper_logger" ], "quality_scale": "bronze", - "requirements": ["momonga==0.3.0"] + "requirements": ["momonga==0.7.0"] } diff --git a/requirements_all.txt b/requirements_all.txt index 792785ac9b7a..59ca55a2d2a6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1650,7 +1650,7 @@ modbus-connection[tmodbus]==4.12.1 moehlenhoff-alpha2==1.4.0 # homeassistant.components.route_b_smart_meter -momonga==0.3.0 +momonga==0.7.0 # homeassistant.components.monarch_money monarchmoneycommunity==1.6.0 diff --git a/tests/components/route_b_smart_meter/test_sensor.py b/tests/components/route_b_smart_meter/test_sensor.py index d9046a2635dc..ddcdfcb40ecf 100644 --- a/tests/components/route_b_smart_meter/test_sensor.py +++ b/tests/components/route_b_smart_meter/test_sensor.py @@ -7,7 +7,7 @@ from momonga import MomongaError from syrupy.assertion import SnapshotAssertion from homeassistant.components.route_b_smart_meter.const import DEFAULT_SCAN_INTERVAL -from homeassistant.const import STATE_UNAVAILABLE +from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import EntityRegistry @@ -57,3 +57,34 @@ async def test_route_b_smart_meter_sensor_no_update( entity = hass.states.get(entity_id) assert entity.state is STATE_UNAVAILABLE + + +async def test_route_b_smart_meter_sensor_no_data( + hass: HomeAssistant, + mock_momonga: Mock, + freezer: FrozenDateTimeFactory, + mock_config_entry: MockConfigEntry, +) -> None: + """Test sensors are unknown when the meter reports no data.""" + entity_prefix = "sensor.route_b_smart_meter_01234567890123456789012345f789_" + await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + client = mock_momonga.return_value + client.get_instantaneous_current.return_value = { + "r phase current": None, + "t phase current": 2, + } + client.get_instantaneous_power.return_value = None + client.get_measured_cumulative_energy.return_value = None + freezer.tick(DEFAULT_SCAN_INTERVAL) + async_fire_time_changed(hass) + await hass.async_block_till_done(wait_background_tasks=True) + + for key in ( + "instantaneous_current_r_phase", + "instantaneous_power", + "total_consumption", + ): + assert hass.states.get(f"{entity_prefix}{key}").state == STATE_UNKNOWN + assert hass.states.get(f"{entity_prefix}instantaneous_current_t_phase").state == "2"