Skip to content

Commit 5dc215a

Browse files
lmaertinjoostlekabmantis
authored
Bump python-pooldose to 0.7.8 (#155307)
Co-authored-by: Joost Lekkerkerker <[email protected]> Co-authored-by: Abílio Costa <[email protected]>
1 parent 306b78b commit 5dc215a

File tree

12 files changed

+144
-27
lines changed

12 files changed

+144
-27
lines changed

homeassistant/components/pooldose/__init__.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
from __future__ import annotations
44

55
import logging
6+
from typing import Any
67

78
from pooldose.client import PooldoseClient
89
from pooldose.request_status import RequestStatus
910

1011
from homeassistant.const import CONF_HOST, Platform
11-
from homeassistant.core import HomeAssistant
12+
from homeassistant.core import HomeAssistant, callback
1213
from homeassistant.exceptions import ConfigEntryNotReady
14+
from homeassistant.helpers import entity_registry as er
1315

1416
from .coordinator import PooldoseConfigEntry, PooldoseCoordinator
1517

@@ -18,6 +20,36 @@
1820
PLATFORMS: list[Platform] = [Platform.SENSOR]
1921

2022

23+
async def async_migrate_entry(hass: HomeAssistant, entry: PooldoseConfigEntry) -> bool:
24+
"""Migrate old entry."""
25+
# Version 1.1 -> 1.2: Migrate entity unique IDs
26+
# - ofa_orp_value -> ofa_orp_time
27+
# - ofa_ph_value -> ofa_ph_time
28+
if entry.version == 1 and entry.minor_version < 2:
29+
30+
@callback
31+
def migrate_unique_id(entity_entry: er.RegistryEntry) -> dict[str, Any] | None:
32+
"""Migrate entity unique IDs for pooldose sensors."""
33+
new_unique_id = entity_entry.unique_id
34+
35+
# Check if this entry needs migration
36+
if "_ofa_orp_value" in new_unique_id:
37+
new_unique_id = new_unique_id.replace("_ofa_orp_value", "_ofa_orp_time")
38+
elif "_ofa_ph_value" in new_unique_id:
39+
new_unique_id = new_unique_id.replace("_ofa_ph_value", "_ofa_ph_time")
40+
else:
41+
# No migration needed
42+
return None
43+
44+
return {"new_unique_id": new_unique_id}
45+
46+
await er.async_migrate_entries(hass, entry.entry_id, migrate_unique_id)
47+
48+
hass.config_entries.async_update_entry(entry, version=1, minor_version=2)
49+
50+
return True
51+
52+
2153
async def async_setup_entry(hass: HomeAssistant, entry: PooldoseConfigEntry) -> bool:
2254
"""Set up Seko PoolDose from a config entry."""
2355
# Get host from config entry data (connection-critical configuration)

homeassistant/components/pooldose/config_flow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class PooldoseConfigFlow(ConfigFlow, domain=DOMAIN):
3131
"""Config flow for the Pooldose integration including DHCP discovery."""
3232

3333
VERSION = 1
34+
MINOR_VERSION = 2
3435

3536
def __init__(self) -> None:
3637
"""Initialize the config flow and store the discovered IP address and MAC."""

homeassistant/components/pooldose/icons.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"entity": {
33
"sensor": {
4-
"ofa_orp_value": {
4+
"ofa_orp_time": {
55
"default": "mdi:clock"
66
},
7-
"ofa_ph_value": {
7+
"ofa_ph_time": {
88
"default": "mdi:clock"
99
},
1010
"orp": {

homeassistant/components/pooldose/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"documentation": "https://www.home-assistant.io/integrations/pooldose",
1212
"iot_class": "local_polling",
1313
"quality_scale": "bronze",
14-
"requirements": ["python-pooldose==0.7.0"]
14+
"requirements": ["python-pooldose==0.7.8"]
1515
}

homeassistant/components/pooldose/sensor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
options=["proportional", "on_off", "timed"],
4949
),
5050
SensorEntityDescription(
51-
key="ofa_ph_value",
52-
translation_key="ofa_ph_value",
51+
key="ofa_ph_time",
52+
translation_key="ofa_ph_time",
5353
entity_category=EntityCategory.DIAGNOSTIC,
5454
device_class=SensorDeviceClass.DURATION,
5555
entity_registry_enabled_default=False,
@@ -72,8 +72,8 @@
7272
options=["off", "proportional", "on_off", "timed"],
7373
),
7474
SensorEntityDescription(
75-
key="ofa_orp_value",
76-
translation_key="ofa_orp_value",
75+
key="ofa_orp_time",
76+
translation_key="ofa_orp_time",
7777
device_class=SensorDeviceClass.DURATION,
7878
entity_category=EntityCategory.DIAGNOSTIC,
7979
entity_registry_enabled_default=False,

homeassistant/components/pooldose/strings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
},
3535
"entity": {
3636
"sensor": {
37-
"ofa_orp_value": {
37+
"ofa_orp_time": {
3838
"name": "ORP overfeed alert time"
3939
},
40-
"ofa_ph_value": {
40+
"ofa_ph_time": {
4141
"name": "pH overfeed alert time"
4242
},
4343
"orp": {

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/pooldose/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@ def mock_config_entry(device_info: dict[str, Any]) -> MockConfigEntry:
7575
)
7676

7777

78+
@pytest.fixture
79+
def mock_config_entry_v1_1(device_info: dict[str, Any]) -> MockConfigEntry:
80+
"""Return a mocked config entry for migration testing with version 1.1."""
81+
return MockConfigEntry(
82+
title="Pool Device",
83+
domain=DOMAIN,
84+
data={CONF_HOST: "192.168.1.100"},
85+
unique_id=device_info["SERIAL_NUMBER"],
86+
version=1,
87+
minor_version=1,
88+
)
89+
90+
7891
async def init_integration(
7992
hass: HomeAssistant, mock_config_entry: MockConfigEntry
8093
) -> MockConfigEntry:

tests/components/pooldose/fixtures/instantvalues.json

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
"value": 718,
1313
"unit": "mV"
1414
},
15+
"cl": {
16+
"value": 1.2,
17+
"unit": "ppm"
18+
},
19+
"flow_rate": {
20+
"value": 150,
21+
"unit": "L/s"
22+
},
1523
"ph_type_dosing": {
1624
"value": "alcalyne",
1725
"unit": null
@@ -20,7 +28,7 @@
2028
"value": "proportional",
2129
"unit": null
2230
},
23-
"ofa_ph_value": {
31+
"ofa_ph_time": {
2432
"value": 0,
2533
"unit": "min"
2634
},
@@ -32,7 +40,7 @@
3240
"value": "proportional",
3341
"unit": null
3442
},
35-
"ofa_orp_value": {
43+
"ofa_orp_time": {
3644
"value": 0,
3745
"unit": "min"
3846
},
@@ -62,25 +70,25 @@
6270
}
6371
},
6472
"binary_sensor": {
65-
"pump_running": {
73+
"pump_alarm": {
6674
"value": true
6775
},
68-
"ph_level_ok": {
76+
"ph_level_alarm": {
6977
"value": false
7078
},
71-
"orp_level_ok": {
79+
"orp_level_alarm": {
7280
"value": false
7381
},
74-
"flow_rate_ok": {
82+
"flow_rate_alarm": {
7583
"value": false
7684
},
7785
"alarm_relay": {
7886
"value": true
7987
},
80-
"relay_aux1_ph": {
88+
"relay_aux1": {
8189
"value": false
8290
},
83-
"relay_aux2_orpcl": {
91+
"relay_aux2": {
8492
"value": false
8593
}
8694
},
@@ -108,10 +116,10 @@
108116
}
109117
},
110118
"switch": {
111-
"stop_pool_dosing": {
119+
"pause_dosing": {
112120
"value": false
113121
},
114-
"pump_detection": {
122+
"pump_monitoring": {
115123
"value": true
116124
},
117125
"frequency_input": {

0 commit comments

Comments
 (0)