Skip to content

Commit b118f03

Browse files
committed
Fix discovers() with new zcc helper
Revert to older AddEntitiesCallback when running in HACS
1 parent 29defc7 commit b118f03

File tree

8 files changed

+54
-28
lines changed

8 files changed

+54
-28
lines changed

custom_components/zimi/cover.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from homeassistant.core import HomeAssistant
1717

1818
# Import the device class from the component that you want to support
19-
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
19+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2020

2121
from . import ZimiConfigEntry
2222
from .entity import ZimiEntity
@@ -27,7 +27,7 @@
2727
async def async_setup_entry(
2828
hass: HomeAssistant,
2929
config_entry: ZimiConfigEntry,
30-
async_add_entities: AddConfigEntryEntitiesCallback,
30+
async_add_entities: AddEntitiesCallback,
3131
) -> None:
3232
"""Set up the Zimi Cover platform."""
3333

@@ -96,7 +96,8 @@ async def async_open_cover(self, **kwargs: Any) -> None:
9696
async def async_set_cover_position(self, **kwargs: Any) -> None:
9797
"""Open the cover/door to a specified percentage."""
9898
if position := kwargs.get("position"):
99-
_LOGGER.debug("Sending set_cover_position(%d) for %s", position, self.name)
99+
_LOGGER.debug("Sending set_cover_position(%d) for %s",
100+
position, self.name)
100101
await self._entity.open_to_percentage(position)
101102

102103
async def async_stop_cover(self, **kwargs: Any) -> None:

custom_components/zimi/fan.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from homeassistant.core import HomeAssistant
1414

1515
# Import the device class from the component that you want to support
16-
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
16+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1717
from homeassistant.util.percentage import (
1818
percentage_to_ranged_value,
1919
ranged_value_to_percentage,
@@ -29,7 +29,7 @@
2929
async def async_setup_entry(
3030
hass: HomeAssistant,
3131
config_entry: ZimiConfigEntry,
32-
async_add_entities: AddConfigEntryEntitiesCallback,
32+
async_add_entities: AddEntitiesCallback,
3333
) -> None:
3434
"""Set up the Zimi Cover platform."""
3535

@@ -62,7 +62,8 @@ def __init__(self, device: ControlPointDevice, api: ControlPoint) -> None:
6262

6363
async def async_set_percentage(self, percentage: int) -> None:
6464
"""Set the desired speed for the fan."""
65-
_LOGGER.debug("Sending async_set_percentage() with percentage %s", percentage)
65+
_LOGGER.debug(
66+
"Sending async_set_percentage() with percentage %s", percentage)
6667

6768
if percentage == 0:
6869
await self.async_turn_off()

custom_components/zimi/light.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from homeassistant.core import HomeAssistant
1313

1414
# Import the device class from the component that you want to support
15-
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
15+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1616

1717
from . import ZimiConfigEntry
1818
from .entity import ZimiEntity
@@ -23,7 +23,7 @@
2323
async def async_setup_entry(
2424
hass: HomeAssistant,
2525
config_entry: ZimiConfigEntry,
26-
async_add_entities: AddConfigEntryEntitiesCallback,
26+
async_add_entities: AddEntitiesCallback,
2727
) -> None:
2828
"""Set up the Zimi Light platform."""
2929

custom_components/zimi/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"quality_scale": "bronze",
1212
"requirements": [
1313
"StrEnum==0.4.15",
14-
"zcc-helper==3.3rc3"
14+
"zcc-helper==3.3rc4"
1515
]
1616
}

custom_components/zimi/sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from homeassistant.core import HomeAssistant
1717

1818
# Import the device class from the component that you want to support
19-
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
19+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2020

2121
from . import ZimiConfigEntry
2222
from .entity import ZimiEntity
@@ -60,7 +60,7 @@
6060
async def async_setup_entry(
6161
hass: HomeAssistant,
6262
config_entry: ZimiConfigEntry,
63-
async_add_entities: AddConfigEntryEntitiesCallback,
63+
async_add_entities: AddEntitiesCallback,
6464
) -> None:
6565
"""Set up the Zimi Sensor platform."""
6666

custom_components/zimi/strings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
4444
}
4545
}
46-
}
46+
}

custom_components/zimi/switch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from homeassistant.core import HomeAssistant
1313

1414
# Import the device class from the component that you want to support
15-
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
15+
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1616

1717
from . import ZimiConfigEntry
1818
from .entity import ZimiEntity
@@ -23,13 +23,14 @@
2323
async def async_setup_entry(
2424
hass: HomeAssistant,
2525
config_entry: ZimiConfigEntry,
26-
async_add_entities: AddConfigEntryEntitiesCallback,
26+
async_add_entities: AddEntitiesCallback,
2727
) -> None:
2828
"""Set up the Zimi Switch platform."""
2929

3030
api: ControlPoint = config_entry.runtime_data
3131

32-
outlets: list[ZimiSwitch] = [ZimiSwitch(device, api) for device in api.outlets]
32+
outlets: list[ZimiSwitch] = [ZimiSwitch(
33+
device, api) for device in api.outlets]
3334

3435
async_add_entities(outlets)
3536

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
{
22
"config": {
3-
"abort": {
4-
"already_configured": "Device is already configured"
5-
},
6-
"error": {
7-
"cannot_connect": "Failed to connect",
8-
"invalid_auth": "Invalid authentication",
9-
"unknown": "Unexpected error"
10-
},
113
"step": {
124
"user": {
5+
"title": "Zimi - Discover Device(s)",
6+
"description": "Discover and auto-configure Zimi Cloud Connect device."
7+
},
8+
"selection": {
9+
"title": "Zimi - Select device",
10+
"description": "Select Zimi Cloud Connect device to configure.",
11+
"data": {
12+
"host": "[%key:common::config_flow::data::host%]",
13+
"port": "[%key:common::config_flow::data::port%]"
14+
}
15+
},
16+
"manual": {
17+
"title": "Zimi - Configure Device",
18+
"description": "Enter details of your Zimi Cloud Connect device.",
1319
"data": {
14-
"host": "Host (optional)",
15-
"port": "Port (optional)",
16-
"verbosity": "Verbosity (0-2)",
17-
"timeout": "Timeout (in secs)",
18-
"watchdog": "Watchdog Timeout (in secs)"
20+
"host": "[%key:common::config_flow::data::host%]",
21+
"port": "[%key:common::config_flow::data::port%]"
22+
},
23+
"data_description": {
24+
"host": "Mandatory - ZCC IP address.",
25+
"port": "Mandatory - ZCC port number (default=5003)."
1926
}
2027
}
28+
},
29+
"error": {
30+
"already_configured": "ZCC device {error_detail} is already configured",
31+
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
32+
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
33+
"unknown": "[%key:common::config_flow::error::unknown%]",
34+
"timeout": "Connection timed out",
35+
"duplicate_entry": "Duplicate configuration entry: {error_detail}",
36+
"invalid_host": "Invalid hostname",
37+
"invalid_mac": "Invalid MAC address",
38+
"mismatched_mac": "Configured MAC mismatch: {error_detail}",
39+
"connection_refused": "Connection refused",
40+
"discovery_failure": "ZCC discovery on LAN failed - manually define host, port and mac."
41+
},
42+
"abort": {
43+
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
2144
}
2245
}
2346
}

0 commit comments

Comments
 (0)