Skip to content

Commit

Permalink
Version 0.10.0
Browse files Browse the repository at this point in the history
Bump growcube-client to 1.2.0
Add automatic reconnect
Update images
Refactor logging
  • Loading branch information
bergdahl committed Jun 29, 2024
1 parent c0a5831 commit d3cd5a4
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 70 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
Home Assistant integration for the [Elecrow GrowCube](https://www.elecrow.com/growcube-gardening-plants-smart-watering-kit-device.html), a smart plant watering device.

> Please note that a Growcube device can only be connected to one client at a time. That means you
> will not be able to connect using the phone app while Home Assistant is running the integration.
> will not be able to connect using the phone app while Home Assistant is running the integration,
> or vice versa.
## Getting help

You can reach me at [#jonnys-place](https://discord.gg/SeHKWPu9Cw) on Brian Lough's Discord.

## Device

![device1.png](https://raw.githubusercontent.com/jonnybergdahl/HomeAssistant_Growcube_Integration/main/images/device1.png)

## Sensors

The integration adds sensors for temperature, humidity and four sensors for moisture. It adds four controls for watering,
this activates the pump for 5 seconds for the given channel.
The integration adds sensors for temperature, humidity and four sensors for moisture.

![sensors1.png](https://raw.githubusercontent.com/jonnybergdahl/HomeAssistant_Growcube_Integration/main/images/sensors1.png)

Expand All @@ -25,7 +29,7 @@ The diagnostics sensors includes things such as device lock, sensor disconnect w

## Controls

There are controls to let you manually water a plant.
There are controls to let you manually water a plant. Thee will activate the pump for 5 seconds for a given outlet.

![controls1.png](https://raw.githubusercontent.com/jonnybergdahl/HomeAssistant_Growcube_Integration/main/images/controls1.png)

Expand Down Expand Up @@ -74,11 +78,3 @@ Install the integration using HACS:

And that's it! Once you've added your GrowCube device, you should be able to see its status and control it from the Home Assistant web interface.

## Getting help

You can reach me in [#jonnys-place](https://discord.gg/SeHKWPu9Cw) on Brian Lough's Discord.

# TODO

- Add/Rename the diagnostics sensors to adhere to the last reverse engineering findings
- Add reconnect logic after connection lost event
1 change: 1 addition & 0 deletions custom_components/growcube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: dict):

return True


async def async_unload_entry(hass: HomeAssistant, entry: dict):
"""Unload the Growcube entry."""
client = hass.data[DOMAIN][entry.entry_id]
Expand Down
42 changes: 29 additions & 13 deletions custom_components/growcube/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update device_locked %s", self._coordinator.data.device_locked)
_LOGGER.debug("%s: Update device_locked %s",
self._coordinator.data.device_id,
self._coordinator.data.device_locked
)
if self._coordinator.data.device_locked != self._attr_native_value:
self._attr_native_value = self._coordinator.data.device_locked
self.schedule_update_ha_state()
Expand Down Expand Up @@ -93,7 +96,10 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update water_state %s", self._coordinator.data.water_warning)
_LOGGER.debug("%s: Update water_state %s",
self._coordinator.data.device_id,
self._coordinator.data.water_warning
)
if self._coordinator.data.water_warning != self._attr_native_value:
self._attr_native_value = self._coordinator.data.water_warning
self.schedule_update_ha_state()
Expand Down Expand Up @@ -129,9 +135,11 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update pump_state[%s] %s",
_LOGGER.debug("%s: Update pump_state[%s] %s",
self._coordinator.data.device_id,
self._channel,
self._coordinator.data.pump_open[self._channel])
self._coordinator.data.pump_open[self._channel]
)
if self._coordinator.data.pump_open[self._channel] != self._attr_native_value:
self._attr_native_value = self._coordinator.data.pump_open[self._channel]
self.schedule_update_ha_state()
Expand Down Expand Up @@ -167,9 +175,11 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update pump_lock_state[%s] %s",
_LOGGER.debug("%s: Update pump_lock_state[%s] %s",
self._coordinator.data.device_id,
self._channel,
self._coordinator.data.outlet_locked_state[self._channel])
self._coordinator.data.outlet_locked_state[self._channel]
)
if self._coordinator.data.outlet_locked_state[self._channel] != self._attr_native_value:
self._attr_native_value = self._coordinator.data.outlet_locked_state[self._channel]
self.schedule_update_ha_state()
Expand All @@ -180,7 +190,7 @@ def __init__(self, coordinator: GrowcubeDataCoordinator, channel: int) -> None:
self._coordinator = coordinator
self._coordinator.entities.append(self)
self._channel = channel
self._attr_unique_id = f"{coordinator.data.device_id}_outlet_" + self.CHANNEL_ID[channel] + "_blocked"
self._attr_unique_id = f"{coordinator.data.device_id}_outlet_" + CHANNEL_ID[channel] + "_blocked"
self.entity_id = f"{Platform.SENSOR}.{self._attr_unique_id}"
self._attr_name = f"Outlet " + CHANNEL_NAME[channel] + " blocked"
self._attr_device_class = BinarySensorDeviceClass.PROBLEM
Expand All @@ -205,9 +215,11 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update pump_lock_state[%s] %s",
_LOGGER.debug("%s: Update pump_lock_state[%s] %s",
self._coordinator.data.device_id,
self._channel,
self._coordinator.data.outlet_blocked_state[self._channel])
self._coordinator.data.outlet_blocked_state[self._channel]
)
if self._coordinator.data.outlet_blocked_state[self._channel] != self._attr_native_value:
self._attr_native_value = self._coordinator.data.outlet_blocked_state[self._channel]
self.schedule_update_ha_state()
Expand Down Expand Up @@ -243,9 +255,11 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update sensor_state[%s] %s",
_LOGGER.debug("%s: Update sensor_state[%s] %s",
self._coordinator.data.device_id,
self._channel,
self._coordinator.data.sensor_abnormal[self._channel])
self._coordinator.data.sensor_abnormal[self._channel]
)
if self._coordinator.data.sensor_abnormal[self._channel] != self._attr_native_value:
self._attr_native_value = self._coordinator.data.sensor_abnormal[self._channel]
self.schedule_update_ha_state()
Expand Down Expand Up @@ -281,9 +295,11 @@ def is_on(self):

@callback
def update(self) -> None:
_LOGGER.debug("Update sensor_state[%s] %s",
_LOGGER.debug("%s: Update sensor_state[%s] %s",
self._coordinator.data.device_id,
self._channel,
self._coordinator.data.sensor_disconnected[self._channel])
self._coordinator.data.sensor_disconnected[self._channel]
)
if self._coordinator.data.sensor_disconnected[self._channel] != self._attr_native_value:
self._attr_native_value = self._coordinator.data.sensor_disconnected[self._channel]
self.schedule_update_ha_state()
Loading

0 comments on commit d3cd5a4

Please sign in to comment.