Skip to content
Open
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
16 changes: 16 additions & 0 deletions custom_components/petlibro/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,22 @@ def extra_state_attributes(self):
value_fn=lambda device: device.feeding_plan_state,
name="Feeding Schedule"
),
PetLibroBinarySensorEntityDescription[GranarySmartFeeder](
key="left_food_low",
translation_key="left_food_low",
icon="mdi:bowl-mix-outline",
device_class=BinarySensorDeviceClass.PROBLEM,
should_report=lambda device: device.left_food_low is not None,
name="Left Food Status"
),
PetLibroBinarySensorEntityDescription[GranarySmartFeeder](
key="right_food_low",
translation_key="right_food_low",
icon="mdi:bowl-mix-outline",
device_class=BinarySensorDeviceClass.PROBLEM,
should_report=lambda device: device.right_food_low is not None,
name="Right Food Status"
),
],
GranarySmartCameraFeeder: [
PetLibroBinarySensorEntityDescription[GranarySmartCameraFeeder](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,34 @@ def battery_state(self) -> str:
def food_dispenser_state(self) -> bool:
return not bool(self._data.get("realInfo", {}).get("grainOutletState", True))

@property
def bowl_mode(self) -> str:
return self._data.get("realInfo", {}).get("bowlMode", "SINGLE_BOWL")

@property
def food_low(self) -> bool:
return not bool(self._data.get("realInfo", {}).get("surplusGrain", True))
surplus = self._data.get("realInfo", {}).get("surplusGrain")
if surplus is not None:
return not bool(surplus)
left = self._data.get("realInfo", {}).get("leftWarehouseSurplusGrain")
right = self._data.get("realInfo", {}).get("rightWarehouseSurplusGrain")
if left is not None and right is not None:
return not bool(left) or not bool(right)
return True

@property
def left_food_low(self) -> bool | None:
value = self._data.get("realInfo", {}).get("leftWarehouseSurplusGrain")
if value is None:
return None
return not bool(value)

@property
def right_food_low(self) -> bool | None:
value = self._data.get("realInfo", {}).get("rightWarehouseSurplusGrain")
if value is None:
return None
return not bool(value)

@property
def unit_type(self) -> int:
Expand Down