Skip to content

Commit f782c78

Browse files
authored
Bump ohmepy and remove advanced_settings_coordinator (home-assistant#156764)
1 parent 139ed34 commit f782c78

File tree

9 files changed

+10
-106
lines changed

9 files changed

+10
-106
lines changed

homeassistant/components/ohme/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from .const import DOMAIN, PLATFORMS
1313
from .coordinator import (
14-
OhmeAdvancedSettingsCoordinator,
1514
OhmeChargeSessionCoordinator,
1615
OhmeConfigEntry,
1716
OhmeDeviceInfoCoordinator,
@@ -56,7 +55,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: OhmeConfigEntry) -> bool
5655

5756
coordinators = (
5857
OhmeChargeSessionCoordinator(hass, entry, client),
59-
OhmeAdvancedSettingsCoordinator(hass, entry, client),
6058
OhmeDeviceInfoCoordinator(hass, entry, client),
6159
)
6260

homeassistant/components/ohme/coordinator.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ohme import ApiException, OhmeApiClient
1111

1212
from homeassistant.config_entries import ConfigEntry
13-
from homeassistant.core import HomeAssistant, callback
13+
from homeassistant.core import HomeAssistant
1414
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
1515

1616
from .const import DOMAIN
@@ -23,7 +23,6 @@ class OhmeRuntimeData:
2323
"""Dataclass to hold ohme coordinators."""
2424

2525
charge_session_coordinator: OhmeChargeSessionCoordinator
26-
advanced_settings_coordinator: OhmeAdvancedSettingsCoordinator
2726
device_info_coordinator: OhmeDeviceInfoCoordinator
2827

2928

@@ -78,31 +77,6 @@ async def _internal_update_data(self) -> None:
7877
await self.client.async_get_charge_session()
7978

8079

81-
class OhmeAdvancedSettingsCoordinator(OhmeBaseCoordinator):
82-
"""Coordinator to pull settings and charger state from the API."""
83-
84-
coordinator_name = "Advanced Settings"
85-
86-
def __init__(
87-
self, hass: HomeAssistant, config_entry: OhmeConfigEntry, client: OhmeApiClient
88-
) -> None:
89-
"""Initialise coordinator."""
90-
super().__init__(hass, config_entry, client)
91-
92-
@callback
93-
def _dummy_listener() -> None:
94-
pass
95-
96-
# This coordinator is used by the API library to determine whether the
97-
# charger is online and available. It is therefore required even if no
98-
# entities are using it.
99-
self.async_add_listener(_dummy_listener)
100-
101-
async def _internal_update_data(self) -> None:
102-
"""Fetch data from API endpoint."""
103-
await self.client.async_get_advanced_settings()
104-
105-
10680
class OhmeDeviceInfoCoordinator(OhmeBaseCoordinator):
10781
"""Coordinator to pull device info and charger settings from the API."""
10882

homeassistant/components/ohme/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"integration_type": "device",
88
"iot_class": "cloud_polling",
99
"quality_scale": "platinum",
10-
"requirements": ["ohme==1.5.2"]
10+
"requirements": ["ohme==1.6.0"]
1111
}

homeassistant/components/ohme/sensor.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OhmeSensorDescription(OhmeEntityDescription, SensorEntityDescription):
3737
value_fn: Callable[[OhmeApiClient], str | int | float | None]
3838

3939

40-
SENSOR_CHARGE_SESSION = [
40+
SENSORS = [
4141
OhmeSensorDescription(
4242
key="status",
4343
translation_key="status",
@@ -91,35 +91,18 @@ class OhmeSensorDescription(OhmeEntityDescription, SensorEntityDescription):
9191
),
9292
]
9393

94-
SENSOR_ADVANCED_SETTINGS = [
95-
OhmeSensorDescription(
96-
key="ct_current",
97-
translation_key="ct_current",
98-
device_class=SensorDeviceClass.CURRENT,
99-
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
100-
value_fn=lambda client: client.power.ct_amps,
101-
is_supported_fn=lambda client: client.ct_connected,
102-
entity_registry_enabled_default=False,
103-
),
104-
]
105-
10694

10795
async def async_setup_entry(
10896
hass: HomeAssistant,
10997
config_entry: OhmeConfigEntry,
11098
async_add_entities: AddConfigEntryEntitiesCallback,
11199
) -> None:
112100
"""Set up sensors."""
113-
coordinators = config_entry.runtime_data
114-
coordinator_map = [
115-
(SENSOR_CHARGE_SESSION, coordinators.charge_session_coordinator),
116-
(SENSOR_ADVANCED_SETTINGS, coordinators.advanced_settings_coordinator),
117-
]
101+
coordinator = config_entry.runtime_data.charge_session_coordinator
118102

119103
async_add_entities(
120104
OhmeSensor(coordinator, description)
121-
for entities, coordinator in coordinator_map
122-
for description in entities
105+
for description in SENSORS
123106
if description.is_supported_fn(coordinator.client)
124107
)
125108

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/components/ohme/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def mock_client():
5252
client = client.return_value
5353
client.async_login.return_value = True
5454
client.status = ChargerStatus.CHARGING
55-
client.power = ChargerPower(0, 0, 0, 0)
55+
client.power = ChargerPower(0, 0, 0)
56+
client.available = True
5657

5758
client.target_soc = 50
5859
client.target_time = (8, 0)

tests/components/ohme/snapshots/test_sensor.ambr

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -47,59 +47,6 @@
4747
'state': 'unknown',
4848
})
4949
# ---
50-
# name: test_sensors[sensor.ohme_home_pro_ct_current-entry]
51-
EntityRegistryEntrySnapshot({
52-
'aliases': set({
53-
}),
54-
'area_id': None,
55-
'capabilities': None,
56-
'config_entry_id': <ANY>,
57-
'config_subentry_id': <ANY>,
58-
'device_class': None,
59-
'device_id': <ANY>,
60-
'disabled_by': None,
61-
'domain': 'sensor',
62-
'entity_category': None,
63-
'entity_id': 'sensor.ohme_home_pro_ct_current',
64-
'has_entity_name': True,
65-
'hidden_by': None,
66-
'icon': None,
67-
'id': <ANY>,
68-
'labels': set({
69-
}),
70-
'name': None,
71-
'options': dict({
72-
'sensor': dict({
73-
'suggested_display_precision': 2,
74-
}),
75-
}),
76-
'original_device_class': <SensorDeviceClass.CURRENT: 'current'>,
77-
'original_icon': None,
78-
'original_name': 'CT current',
79-
'platform': 'ohme',
80-
'previous_unique_id': None,
81-
'suggested_object_id': None,
82-
'supported_features': 0,
83-
'translation_key': 'ct_current',
84-
'unique_id': 'chargerid_ct_current',
85-
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
86-
})
87-
# ---
88-
# name: test_sensors[sensor.ohme_home_pro_ct_current-state]
89-
StateSnapshot({
90-
'attributes': ReadOnlyDict({
91-
'device_class': 'current',
92-
'friendly_name': 'Ohme Home Pro CT current',
93-
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
94-
}),
95-
'context': <ANY>,
96-
'entity_id': 'sensor.ohme_home_pro_ct_current',
97-
'last_changed': <ANY>,
98-
'last_reported': <ANY>,
99-
'last_updated': <ANY>,
100-
'state': '0',
101-
})
102-
# ---
10350
# name: test_sensors[sensor.ohme_home_pro_current-entry]
10451
EntityRegistryEntrySnapshot({
10552
'aliases': set({

tests/components/ohme/snapshots/test_services.ambr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
dict({
66
'end': '2024-12-30T04:30:39+00:00',
77
'energy': 2.042,
8+
'power': 4.0,
89
'start': '2024-12-30T04:00:00+00:00',
910
}),
1011
]),

0 commit comments

Comments
 (0)