Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hydrawise zone addressing #97333

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/hydrawise/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ def _handle_coordinator_update(self) -> None:
if self.entity_description.key == "status":
self._attr_is_on = self.coordinator.api.status == "All good!"
elif self.entity_description.key == "is_watering":
relay_data = self.coordinator.api.relays[self.data["relay"] - 1]
relay_data = self.coordinator.api.relays_by_zone_number[self.data["relay"]]
self._attr_is_on = relay_data["timestr"] == "Now"
super()._handle_coordinator_update()
2 changes: 1 addition & 1 deletion homeassistant/components/hydrawise/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class HydrawiseSensor(HydrawiseEntity, SensorEntity):
def _handle_coordinator_update(self) -> None:
"""Get the latest data and updates the states."""
LOGGER.debug("Updating Hydrawise sensor: %s", self.name)
relay_data = self.coordinator.api.relays[self.data["relay"] - 1]
relay_data = self.coordinator.api.relays_by_zone_number[self.data["relay"]]
if self.entity_description.key == "watering_time":
if relay_data["timestr"] == "Now":
self._attr_native_value = int(relay_data["run"] / 60)
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/hydrawise/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,26 @@ def __init__(

def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
relay_data = self.data["relay"] - 1
zone_number = self.data["relay"]
if self.entity_description.key == "manual_watering":
self.coordinator.api.run_zone(self._default_watering_timer, relay_data)
self.coordinator.api.run_zone(self._default_watering_timer, zone_number)
elif self.entity_description.key == "auto_watering":
self.coordinator.api.suspend_zone(0, relay_data)
self.coordinator.api.suspend_zone(0, zone_number)

def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
relay_data = self.data["relay"] - 1
zone_number = self.data["relay"]
if self.entity_description.key == "manual_watering":
self.coordinator.api.run_zone(0, relay_data)
self.coordinator.api.run_zone(0, zone_number)
elif self.entity_description.key == "auto_watering":
self.coordinator.api.suspend_zone(365, relay_data)
self.coordinator.api.suspend_zone(365, zone_number)

@callback
def _handle_coordinator_update(self) -> None:
"""Update device state."""
relay_data = self.data["relay"] - 1
zone_number = self.data["relay"]
LOGGER.debug("Updating Hydrawise switch: %s", self.name)
timestr = self.coordinator.api.relays[relay_data]["timestr"]
timestr = self.coordinator.api.relays_by_zone_number[zone_number]["timestr"]
if self.entity_description.key == "manual_watering":
self._attr_is_on = timestr == "Now"
elif self.entity_description.key == "auto_watering":
Expand Down