diff --git a/homeassistant/components/hydrawise/const.py b/homeassistant/components/hydrawise/const.py index dc53d847b1f..724b6ee6203 100644 --- a/homeassistant/components/hydrawise/const.py +++ b/homeassistant/components/hydrawise/const.py @@ -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" diff --git a/homeassistant/components/hydrawise/switch.py b/homeassistant/components/hydrawise/switch.py index 5dd79d4a13e..5a3a3a62895 100644 --- a/homeassistant/components/hydrawise/switch.py +++ b/homeassistant/components/hydrawise/switch.py @@ -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) diff --git a/tests/components/hydrawise/test_switch.py b/tests/components/hydrawise/test_switch.py index 30a58735122..f044d3467cd 100644 --- a/tests/components/hydrawise/test_switch.py +++ b/tests/components/hydrawise/test_switch.py @@ -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