Fix Hydrawise watering time duration unit (#105919)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>pull/106475/head
parent
2497798b5d
commit
7746a94543
|
@ -9,7 +9,7 @@ ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60]
|
||||||
CONF_WATERING_TIME = "watering_minutes"
|
CONF_WATERING_TIME = "watering_minutes"
|
||||||
|
|
||||||
DOMAIN = "hydrawise"
|
DOMAIN = "hydrawise"
|
||||||
DEFAULT_WATERING_TIME = 15
|
DEFAULT_WATERING_TIME = timedelta(minutes=15)
|
||||||
|
|
||||||
MANUFACTURER = "Hydrawise"
|
MANUFACTURER = "Hydrawise"
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
vol.Optional(CONF_MONITORED_CONDITIONS, default=SWITCH_KEYS): vol.All(
|
vol.Optional(CONF_MONITORED_CONDITIONS, default=SWITCH_KEYS): vol.All(
|
||||||
cv.ensure_list, [vol.In(SWITCH_KEYS)]
|
cv.ensure_list, [vol.In(SWITCH_KEYS)]
|
||||||
),
|
),
|
||||||
vol.Optional(CONF_WATERING_TIME, default=DEFAULT_WATERING_TIME): vol.All(
|
vol.Optional(
|
||||||
vol.In(ALLOWED_WATERING_TIME)
|
CONF_WATERING_TIME, default=DEFAULT_WATERING_TIME.total_seconds() // 60
|
||||||
),
|
): vol.All(vol.In(ALLOWED_WATERING_TIME)),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
if self.entity_description.key == "manual_watering":
|
if self.entity_description.key == "manual_watering":
|
||||||
await self.coordinator.api.start_zone(
|
await self.coordinator.api.start_zone(
|
||||||
self.zone, custom_run_duration=DEFAULT_WATERING_TIME
|
self.zone, custom_run_duration=DEFAULT_WATERING_TIME.total_seconds()
|
||||||
)
|
)
|
||||||
elif self.entity_description.key == "auto_watering":
|
elif self.entity_description.key == "auto_watering":
|
||||||
await self.coordinator.api.resume_zone(self.zone)
|
await self.coordinator.api.resume_zone(self.zone)
|
||||||
|
|
|
@ -51,7 +51,7 @@ async def test_manual_watering_services(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
mock_pydrawise.start_zone.assert_called_once_with(
|
mock_pydrawise.start_zone.assert_called_once_with(
|
||||||
zones[0], custom_run_duration=DEFAULT_WATERING_TIME
|
zones[0], custom_run_duration=DEFAULT_WATERING_TIME.total_seconds()
|
||||||
)
|
)
|
||||||
state = hass.states.get("switch.zone_one_manual_watering")
|
state = hass.states.get("switch.zone_one_manual_watering")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
|
|
Loading…
Reference in New Issue