Fix Hydrawise watering time duration unit (#105919)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/106475/head
David Knowles 2023-12-27 07:20:09 -05:00 committed by GitHub
parent 2497798b5d
commit 7746a94543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@ ALLOWED_WATERING_TIME = [5, 10, 15, 30, 45, 60]
CONF_WATERING_TIME = "watering_minutes"
DOMAIN = "hydrawise"
DEFAULT_WATERING_TIME = 15
DEFAULT_WATERING_TIME = timedelta(minutes=15)
MANUFACTURER = "Hydrawise"

View File

@ -52,9 +52,9 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
vol.Optional(CONF_MONITORED_CONDITIONS, default=SWITCH_KEYS): vol.All(
cv.ensure_list, [vol.In(SWITCH_KEYS)]
),
vol.Optional(CONF_WATERING_TIME, default=DEFAULT_WATERING_TIME): vol.All(
vol.In(ALLOWED_WATERING_TIME)
),
vol.Optional(
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."""
if self.entity_description.key == "manual_watering":
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":
await self.coordinator.api.resume_zone(self.zone)

View File

@ -51,7 +51,7 @@ async def test_manual_watering_services(
blocking=True,
)
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")
assert state is not None