From dabaa2bc5e30e3885acda4670e5fa663c67ebdf3 Mon Sep 17 00:00:00 2001 From: Dan Raper Date: Tue, 18 Nov 2025 18:52:17 +0000 Subject: [PATCH] Bump ohmepy and remove advanced_settings_coordinator (#156764) --- homeassistant/components/ohme/__init__.py | 2 - homeassistant/components/ohme/coordinator.py | 28 +--------- homeassistant/components/ohme/manifest.json | 2 +- homeassistant/components/ohme/sensor.py | 23 ++------ requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/ohme/conftest.py | 3 +- .../ohme/snapshots/test_sensor.ambr | 53 ------------------- .../ohme/snapshots/test_services.ambr | 1 + 9 files changed, 10 insertions(+), 106 deletions(-) diff --git a/homeassistant/components/ohme/__init__.py b/homeassistant/components/ohme/__init__.py index c304bfdf72d..6ed86c183ef 100644 --- a/homeassistant/components/ohme/__init__.py +++ b/homeassistant/components/ohme/__init__.py @@ -11,7 +11,6 @@ from homeassistant.helpers.typing import ConfigType from .const import DOMAIN, PLATFORMS from .coordinator import ( - OhmeAdvancedSettingsCoordinator, OhmeChargeSessionCoordinator, OhmeConfigEntry, OhmeDeviceInfoCoordinator, @@ -56,7 +55,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: OhmeConfigEntry) -> bool coordinators = ( OhmeChargeSessionCoordinator(hass, entry, client), - OhmeAdvancedSettingsCoordinator(hass, entry, client), OhmeDeviceInfoCoordinator(hass, entry, client), ) diff --git a/homeassistant/components/ohme/coordinator.py b/homeassistant/components/ohme/coordinator.py index d9e009ed1f1..71ac7e1794f 100644 --- a/homeassistant/components/ohme/coordinator.py +++ b/homeassistant/components/ohme/coordinator.py @@ -10,7 +10,7 @@ import logging from ohme import ApiException, OhmeApiClient from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant, callback +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import DOMAIN @@ -23,7 +23,6 @@ class OhmeRuntimeData: """Dataclass to hold ohme coordinators.""" charge_session_coordinator: OhmeChargeSessionCoordinator - advanced_settings_coordinator: OhmeAdvancedSettingsCoordinator device_info_coordinator: OhmeDeviceInfoCoordinator @@ -78,31 +77,6 @@ class OhmeChargeSessionCoordinator(OhmeBaseCoordinator): await self.client.async_get_charge_session() -class OhmeAdvancedSettingsCoordinator(OhmeBaseCoordinator): - """Coordinator to pull settings and charger state from the API.""" - - coordinator_name = "Advanced Settings" - - def __init__( - self, hass: HomeAssistant, config_entry: OhmeConfigEntry, client: OhmeApiClient - ) -> None: - """Initialise coordinator.""" - super().__init__(hass, config_entry, client) - - @callback - def _dummy_listener() -> None: - pass - - # This coordinator is used by the API library to determine whether the - # charger is online and available. It is therefore required even if no - # entities are using it. - self.async_add_listener(_dummy_listener) - - async def _internal_update_data(self) -> None: - """Fetch data from API endpoint.""" - await self.client.async_get_advanced_settings() - - class OhmeDeviceInfoCoordinator(OhmeBaseCoordinator): """Coordinator to pull device info and charger settings from the API.""" diff --git a/homeassistant/components/ohme/manifest.json b/homeassistant/components/ohme/manifest.json index 14612fff6eb..e3677b26215 100644 --- a/homeassistant/components/ohme/manifest.json +++ b/homeassistant/components/ohme/manifest.json @@ -7,5 +7,5 @@ "integration_type": "device", "iot_class": "cloud_polling", "quality_scale": "platinum", - "requirements": ["ohme==1.5.2"] + "requirements": ["ohme==1.6.0"] } diff --git a/homeassistant/components/ohme/sensor.py b/homeassistant/components/ohme/sensor.py index 7047e33749f..93063966050 100644 --- a/homeassistant/components/ohme/sensor.py +++ b/homeassistant/components/ohme/sensor.py @@ -37,7 +37,7 @@ class OhmeSensorDescription(OhmeEntityDescription, SensorEntityDescription): value_fn: Callable[[OhmeApiClient], str | int | float | None] -SENSOR_CHARGE_SESSION = [ +SENSORS = [ OhmeSensorDescription( key="status", translation_key="status", @@ -91,18 +91,6 @@ SENSOR_CHARGE_SESSION = [ ), ] -SENSOR_ADVANCED_SETTINGS = [ - OhmeSensorDescription( - key="ct_current", - translation_key="ct_current", - device_class=SensorDeviceClass.CURRENT, - native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, - value_fn=lambda client: client.power.ct_amps, - is_supported_fn=lambda client: client.ct_connected, - entity_registry_enabled_default=False, - ), -] - async def async_setup_entry( hass: HomeAssistant, @@ -110,16 +98,11 @@ async def async_setup_entry( async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up sensors.""" - coordinators = config_entry.runtime_data - coordinator_map = [ - (SENSOR_CHARGE_SESSION, coordinators.charge_session_coordinator), - (SENSOR_ADVANCED_SETTINGS, coordinators.advanced_settings_coordinator), - ] + coordinator = config_entry.runtime_data.charge_session_coordinator async_add_entities( OhmeSensor(coordinator, description) - for entities, coordinator in coordinator_map - for description in entities + for description in SENSORS if description.is_supported_fn(coordinator.client) ) diff --git a/requirements_all.txt b/requirements_all.txt index bd58b95c5d3..88bb952bee9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1618,7 +1618,7 @@ odp-amsterdam==6.1.2 oemthermostat==1.1.1 # homeassistant.components.ohme -ohme==1.5.2 +ohme==1.6.0 # homeassistant.components.ollama ollama==0.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 950446af5ed..11ca5f9e149 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1389,7 +1389,7 @@ objgraph==3.5.0 odp-amsterdam==6.1.2 # homeassistant.components.ohme -ohme==1.5.2 +ohme==1.6.0 # homeassistant.components.ollama ollama==0.5.1 diff --git a/tests/components/ohme/conftest.py b/tests/components/ohme/conftest.py index e8a7d27b2c3..2a830a5bfc8 100644 --- a/tests/components/ohme/conftest.py +++ b/tests/components/ohme/conftest.py @@ -52,7 +52,8 @@ def mock_client(): client = client.return_value client.async_login.return_value = True client.status = ChargerStatus.CHARGING - client.power = ChargerPower(0, 0, 0, 0) + client.power = ChargerPower(0, 0, 0) + client.available = True client.target_soc = 50 client.target_time = (8, 0) diff --git a/tests/components/ohme/snapshots/test_sensor.ambr b/tests/components/ohme/snapshots/test_sensor.ambr index c22d43a451b..f074aa8e6bd 100644 --- a/tests/components/ohme/snapshots/test_sensor.ambr +++ b/tests/components/ohme/snapshots/test_sensor.ambr @@ -47,59 +47,6 @@ 'state': 'unknown', }) # --- -# name: test_sensors[sensor.ohme_home_pro_ct_current-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.ohme_home_pro_ct_current', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - 'sensor': dict({ - 'suggested_display_precision': 2, - }), - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'CT current', - 'platform': 'ohme', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': 'ct_current', - 'unique_id': 'chargerid_ct_current', - 'unit_of_measurement': , - }) -# --- -# name: test_sensors[sensor.ohme_home_pro_ct_current-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'current', - 'friendly_name': 'Ohme Home Pro CT current', - 'unit_of_measurement': , - }), - 'context': , - 'entity_id': 'sensor.ohme_home_pro_ct_current', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': '0', - }) -# --- # name: test_sensors[sensor.ohme_home_pro_current-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/ohme/snapshots/test_services.ambr b/tests/components/ohme/snapshots/test_services.ambr index 91917ed6925..c7c0deaefdb 100644 --- a/tests/components/ohme/snapshots/test_services.ambr +++ b/tests/components/ohme/snapshots/test_services.ambr @@ -5,6 +5,7 @@ dict({ 'end': '2024-12-30T04:30:39+00:00', 'energy': 2.042, + 'power': 4.0, 'start': '2024-12-30T04:00:00+00:00', }), ]),