Skip to content

Commit 49f28d3

Browse files
committed
fixes issue #43: incorrect zone identification when invoking set_moisture service (affects only Netro API v2 usage)
1 parent 6f34701 commit 49f28d3

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

custom_components/netro_watering/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
335335
return True
336336

337337

338-
async def async_setup_entry(
339-
hass: HomeAssistant, entry: ConfigEntry
340-
) -> bool: # noqa: C901
338+
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # noqa: C901
341339
"""Set up Netro Watering from a config entry."""
342340

343341
_LOGGER.debug(
@@ -679,7 +677,11 @@ async def set_moisture(call: ServiceCall) -> None:
679677
if identifier[1].startswith(key):
680678
# assume that device info returned by Zone class is
681679
# <controller_serial>_<zone_id> as identifiers
682-
zone_id = identifier[1].split("_")[1]
680+
zone_id = identifier[1].rsplit("_", 1)[-1]
681+
if not zone_id.isdigit():
682+
raise HomeAssistantError(
683+
f"Could not extract a zone number from identifier '{identifier[1]}'"
684+
)
683685
break
684686

685687
# set moisture by Netro

custom_components/netro_watering/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"issue_tracker": "https://github.com/kcofoni/ha-netro-watering/issues",
1111
"requirements": ["pynetro==0.1.5", "validators==0.20.0"],
1212
"ssdp": [],
13-
"version": "1.4.0",
13+
"version": "1.4.1",
1414
"zeroconf": []
1515
}

0 commit comments

Comments
 (0)