From 2d9fddd036d5a1d6dd7d8a5fbe449393ca20ac5c Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:14:42 -0400 Subject: [PATCH 01/30] Update __init__.py Added support for using Product ID instead of name --- custom_components/petlibro/devices/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 8c2f312..5f24fe1 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -7,3 +7,8 @@ "Granary Feeder": GranaryFeeder, "Granary Camera Feeder": GranaryCameraFeeder } + +prodcut_id_map: Dict[str, Type[Device]] = { + "PLAF103": GranaryFeeder, + "PLAF203": GranaryCameraFeeder +} From 717519c82f0c156647b190752b4c890a8bd474c6 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:16:09 -0400 Subject: [PATCH 02/30] Update hub.py Changed to use productIdentifier instead of name --- custom_components/petlibro/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 981cb48..1ae8707 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -52,7 +52,7 @@ async def load_devices(self): if device := await self.get_device(device_data["deviceSn"]): await device.refresh() else: - if device_data["productName"] in product_name_map: + if device_data["productIdentifier"] in product_name_map: device = product_name_map[device_data["productName"]](device_data, self.api) await device.refresh() # Get all API data self.devices.append(device) From 7592d03b37704aeb778815d49ee1cbb440089600 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:25:32 -0400 Subject: [PATCH 03/30] Update hub.py Fixed using ID --- custom_components/petlibro/hub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 1ae8707..23b186c 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -53,11 +53,11 @@ async def load_devices(self): await device.refresh() else: if device_data["productIdentifier"] in product_name_map: - device = product_name_map[device_data["productName"]](device_data, self.api) + device = product_name_map[device_data["productIdentifier"]](device_data, self.api) await device.refresh() # Get all API data self.devices.append(device) else: - _LOGGER.error("Unsupported device found: %s", device_data["productName"]) + _LOGGER.error("Unsupported device found: %s", device_data["productIdentifier"]) async def refresh_devices(self) -> bool: """Update all known devices states from the PETLIBRO API.""" From 87a05242a68006554fca9636d819a4b21019fe22 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:43:01 -0400 Subject: [PATCH 04/30] Update hub.py Using product_id_map --- custom_components/petlibro/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 23b186c..fa693aa 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -52,7 +52,7 @@ async def load_devices(self): if device := await self.get_device(device_data["deviceSn"]): await device.refresh() else: - if device_data["productIdentifier"] in product_name_map: + if device_data["productIdentifier"] in product_id_map: device = product_name_map[device_data["productIdentifier"]](device_data, self.api) await device.refresh() # Get all API data self.devices.append(device) From 8f5abcc441d563e185b641439c30e5f14db6a4a8 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:49:49 -0400 Subject: [PATCH 05/30] Update __init__.py Fixed spelling of product --- custom_components/petlibro/devices/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 5f24fe1..46ed48a 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -8,7 +8,7 @@ "Granary Camera Feeder": GranaryCameraFeeder } -prodcut_id_map: Dict[str, Type[Device]] = { +product_id_map: Dict[str, Type[Device]] = { "PLAF103": GranaryFeeder, "PLAF203": GranaryCameraFeeder } From fb5da0db593ce050addc78e78a6d0963222c9b90 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 20:59:55 -0400 Subject: [PATCH 06/30] Update __init__.py --- custom_components/petlibro/devices/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 46ed48a..1719d5c 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -8,7 +8,7 @@ "Granary Camera Feeder": GranaryCameraFeeder } -product_id_map: Dict[str, Type[Device]] = { +product_id_map : Dict[str, Type[Device]] = { "PLAF103": GranaryFeeder, "PLAF203": GranaryCameraFeeder } From 916ad01943bf03323a07f80763c3667919946fef Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 21:03:39 -0400 Subject: [PATCH 07/30] Update hub.py Added support for product_id_map --- custom_components/petlibro/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index fa693aa..6c166f3 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -14,7 +14,7 @@ from .const import DOMAIN from .api import PetLibroAPIError -from .devices import Device, product_name_map +from .devices import Device, product_name_map, product_id_map _LOGGER = getLogger(__name__) UPDATE_INTERVAL_SECONDS = 60 * 5 From a6a00bc6258fd30757c1eb97847f6820b18fbe88 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 21:07:15 -0400 Subject: [PATCH 08/30] Update hub.py More changes to use ID --- custom_components/petlibro/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 6c166f3..23835f5 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -53,7 +53,7 @@ async def load_devices(self): await device.refresh() else: if device_data["productIdentifier"] in product_id_map: - device = product_name_map[device_data["productIdentifier"]](device_data, self.api) + device = product_id_map[device_data["productIdentifier"]](device_data, self.api) await device.refresh() # Get all API data self.devices.append(device) else: From a586cc4da56a3e3b3a7747c0b1a01c49be391833 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Sun, 29 Sep 2024 21:19:56 -0400 Subject: [PATCH 09/30] Update feeder.py trying truncating again Update feeder.py Truncate amount to 2 decimal points Update feeder.py truncated to 2 decimal points, changed cup to cups Update feeder.py trying again --- custom_components/petlibro/devices/feeders/feeder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/petlibro/devices/feeders/feeder.py b/custom_components/petlibro/devices/feeders/feeder.py index c8acb56..e813751 100644 --- a/custom_components/petlibro/devices/feeders/feeder.py +++ b/custom_components/petlibro/devices/feeders/feeder.py @@ -4,7 +4,7 @@ UNITS = { - 1: "cup", + 1: "cups", 2: "oz", 3: "g", 4: "mL" @@ -62,8 +62,8 @@ def convert_unit(self, value: int) -> int: Convert a value to the device unit :param unit: Value to convert - :return: Converted value or unchanged if no unit + :return: Converted value or unchanged if no unit (truncated to 2 decimal points) """ if self.unit_id: - return value * UNITS_RATIO.get(self.unit_id, 1) - return value + return float('%.2f'%(value)) * UNITS_RATIO.get(self.unit_id, 1) + return float('%.2f'%(value)) From af99b201ea07194c0ef7f9d19f710c709d6eb274 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 07:49:48 -0400 Subject: [PATCH 10/30] Revert "Update feeder.py" This reverts commit a586cc4da56a3e3b3a7747c0b1a01c49be391833. --- custom_components/petlibro/devices/feeders/feeder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/petlibro/devices/feeders/feeder.py b/custom_components/petlibro/devices/feeders/feeder.py index e813751..c8acb56 100644 --- a/custom_components/petlibro/devices/feeders/feeder.py +++ b/custom_components/petlibro/devices/feeders/feeder.py @@ -4,7 +4,7 @@ UNITS = { - 1: "cups", + 1: "cup", 2: "oz", 3: "g", 4: "mL" @@ -62,8 +62,8 @@ def convert_unit(self, value: int) -> int: Convert a value to the device unit :param unit: Value to convert - :return: Converted value or unchanged if no unit (truncated to 2 decimal points) + :return: Converted value or unchanged if no unit """ if self.unit_id: - return float('%.2f'%(value)) * UNITS_RATIO.get(self.unit_id, 1) - return float('%.2f'%(value)) + return value * UNITS_RATIO.get(self.unit_id, 1) + return value From fac8aec81379a76ffbd62ce80c342c541841cc9e Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 08:03:27 -0400 Subject: [PATCH 11/30] attempting to add fountain support --- .../petlibro/devices/__init__.py | 4 ++- .../devices/fountains/dockstream_fountain.py | 31 +++++++++++++++++++ .../petlibro/devices/fountains/fountain.py | 29 ++++++++++++++++- custom_components/petlibro/hub.py | 2 +- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 custom_components/petlibro/devices/fountains/dockstream_fountain.py diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 1719d5c..2558216 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -2,6 +2,7 @@ from .device import Device from .feeders.granary_feeder import GranaryFeeder from .feeders.granary_camera_feeder import GranaryCameraFeeder +from .fountains.dockstream_fountain import DockstreamFountain product_name_map : Dict[str, Type[Device]] = { "Granary Feeder": GranaryFeeder, @@ -10,5 +11,6 @@ product_id_map : Dict[str, Type[Device]] = { "PLAF103": GranaryFeeder, - "PLAF203": GranaryCameraFeeder + "PLAF203": GranaryCameraFeeder, + "PLWF105": DockstreamFountain, } diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py new file mode 100644 index 0000000..31c7d27 --- /dev/null +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -0,0 +1,31 @@ +from typing import cast + +from .fountain import Fountain + + +class DockstreamFountain(Fountain): + async def refresh(self): + await super().refresh() + self.update_data({ + "grainStatus": await self.api.device_grain_status(self.serial) + }) + + @property + def remaining_cleaning(self) -> str: + return cast(str, self._data.get("remainingCleaningDays")) + + @property + def remaining_replacement_days(self) -> str: + return cast(str, self._data.get("remainingReplacementDays")) + + @property + def today_totalMl(self) -> int: + quantity = self._data.get("totalTotalMl") + if not quantity: + return 0 + + return self.convert_unit(quantity) + + @property + def weight_percent(self) -> int: + return cast(int, self._data.get("weightPercent")) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 8f952c1..3d5a0b6 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -1,5 +1,32 @@ +from typing import Optional, cast from . import Device +UNITS = { + 1: "cup", + 2: "oz", + 3: "g", + 4: "mL" +} class Fountain(Device): - pass + async def refresh(self): + await super().refresh() + self.update_data({ + "feedingPlanTodayNew": await self.api.device_feeding_plan_today_new(self.serial) + }) + + @property + def unit_id(self) -> int | None: + """The device unit type identifier""" + return self._data.get("unitType") + + @property + def unit_type(self) -> str | None: + """The device unit type""" + unit : Optional[str] = None + + if unit_id := self.unit_id: + unit = UNITS.get(unit_id) + + return unit + diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 23835f5..3573620 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -57,7 +57,7 @@ async def load_devices(self): await device.refresh() # Get all API data self.devices.append(device) else: - _LOGGER.error("Unsupported device found: %s", device_data["productIdentifier"]) + _LOGGER.info("Unsupported device found: %s", device_data["productIdentifier"]) async def refresh_devices(self) -> bool: """Update all known devices states from the PETLIBRO API.""" From 6261df3c8f31a570b90f5dde8278c3d34275345a Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 08:19:22 -0400 Subject: [PATCH 12/30] adding sensors for fountain --- custom_components/petlibro/sensor.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 6f9058b..2d3f0eb 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -19,6 +19,8 @@ from .devices import Device from .devices.feeders.feeder import Feeder from .devices.feeders.granary_feeder import GranaryFeeder +from .devices.fountains.fountain import Fountain +from .devices.fountains.dockstream_fountain import DockstreamFountain from . import PetLibroHubConfigEntry from .entity import PetLibroEntity, _DeviceT, PetLibroEntityDescription @@ -46,6 +48,16 @@ def device_class_feeder(device: Feeder) -> SensorDeviceClass | None: return SensorDeviceClass.WEIGHT if device.unit_type in ["cup", UnitOfVolume.MILLILITERS]: return SensorDeviceClass.VOLUME + + +def unit_of_measurement_fountain(device: Fountain) -> str | None: + return device.unit_type + +def device_class_fountain(device: Fountain) -> SensorDeviceClass | None: + if device.unit_type in [UnitOfMass.OUNCES, UnitOfMass.GRAMS]: + return SensorDeviceClass.WEIGHT + if device.unit_type in ["cup", UnitOfVolume.MILLILITERS]: + return SensorDeviceClass.VOLUME @dataclass(frozen=True) @@ -115,6 +127,26 @@ def device_class(self) -> SensorDeviceClass | None: icon="mdi:history", state_class=SensorStateClass.TOTAL_INCREASING ) + ], + DockstreamFountain: [ + PetLibroSensorEntityDescription[DockstreamFountain]( + key="remaining_cleaning", + translation_key="remaining_cleaning", + icon="mdi:calendar-clock" + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="remaining_replacement_days", + translation_key="remaining_replacement_days", + icon="mdi:calendar-clock" + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="today_totalMl", + translation_key="today_totalMl", + icon="mdi:water", + native_unit_of_measurement_fn=unit_of_measurement_fountain, + device_class_fn=device_class_fountain, + state_class=SensorStateClass.INCREASING + ) ] } From 7c16b28335c1b012fc1e335e3f495ebd02e5a712 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 08:23:29 -0400 Subject: [PATCH 13/30] fixed sensor class --- custom_components/petlibro/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 2d3f0eb..22c2a19 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -145,7 +145,7 @@ def device_class(self) -> SensorDeviceClass | None: icon="mdi:water", native_unit_of_measurement_fn=unit_of_measurement_fountain, device_class_fn=device_class_fountain, - state_class=SensorStateClass.INCREASING + state_class=SensorStateClass.TOTAL_INCREASING ) ] } From 4a91f7d22690b5095975c5eb54f54b1254914abd Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 08:36:37 -0400 Subject: [PATCH 14/30] adding weight percent --- custom_components/petlibro/sensor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 22c2a19..40ebc6c 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -146,6 +146,11 @@ def device_class(self) -> SensorDeviceClass | None: native_unit_of_measurement_fn=unit_of_measurement_fountain, device_class_fn=device_class_fountain, state_class=SensorStateClass.TOTAL_INCREASING + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="weight_percent", + translation_key="weight_percent", + icon="mdi:percent", ) ] } From 414f2d9f1bde2fd6ab50c4528ce3866be4cb0c8e Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 09:27:47 -0400 Subject: [PATCH 15/30] added labels for water --- .../petlibro/translations/en.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/custom_components/petlibro/translations/en.json b/custom_components/petlibro/translations/en.json index 37d5715..985e32c 100644 --- a/custom_components/petlibro/translations/en.json +++ b/custom_components/petlibro/translations/en.json @@ -35,7 +35,26 @@ }, "today_feeding_times": { "name": "Today's feeding times" + }, + "today_water_quantity": { + "name": "Today's water quantity" + }, + "today_water_times": { + "name": "Today's water times" + }, + "remaining_cleaning": { + "name": "Cleaning remaining days" + }, + "remaining_filter": { + "name": "Filter remaining days" + }, + "weight_percent": { + "name": "Water Remaining" + }, + "today_totalMl": { + "name": "Today's total water" } + }, "switch": { "feeding_plan": { From 41075f68235dae8e27123d69f66560ecf71e23d7 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 09:35:26 -0400 Subject: [PATCH 16/30] fixing labels --- .../petlibro/devices/fountains/dockstream_fountain.py | 2 +- custom_components/petlibro/translations/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py index 31c7d27..51ca65f 100644 --- a/custom_components/petlibro/devices/fountains/dockstream_fountain.py +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -20,7 +20,7 @@ def remaining_replacement_days(self) -> str: @property def today_totalMl(self) -> int: - quantity = self._data.get("totalTotalMl") + quantity = self._data.get("todayTotalMl") if not quantity: return 0 diff --git a/custom_components/petlibro/translations/en.json b/custom_components/petlibro/translations/en.json index 985e32c..f458756 100644 --- a/custom_components/petlibro/translations/en.json +++ b/custom_components/petlibro/translations/en.json @@ -45,7 +45,7 @@ "remaining_cleaning": { "name": "Cleaning remaining days" }, - "remaining_filter": { + "remaining_replacement_days": { "name": "Filter remaining days" }, "weight_percent": { From ee0fa595b93960fe3a37cd3b039e8e273935537a Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 09:44:05 -0400 Subject: [PATCH 17/30] trying to get the water today to show up --- custom_components/petlibro/devices/fountains/fountain.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 3d5a0b6..a7ca304 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -30,3 +30,5 @@ def unit_type(self) -> str | None: return unit + def convert_unit(self, value: int) -> int: + return value \ No newline at end of file From 53b2b223b54f5d8ff936178fa6f7b452946bd4fa Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 09:52:10 -0400 Subject: [PATCH 18/30] trying a device class --- custom_components/petlibro/sensor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 40ebc6c..94c5d95 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -145,12 +145,14 @@ def device_class(self) -> SensorDeviceClass | None: icon="mdi:water", native_unit_of_measurement_fn=unit_of_measurement_fountain, device_class_fn=device_class_fountain, + device_class=SensorDeviceClass.VOLUME, state_class=SensorStateClass.TOTAL_INCREASING ), PetLibroSensorEntityDescription[DockstreamFountain]( key="weight_percent", translation_key="weight_percent", icon="mdi:percent", + device_class=SensorDeviceClass.BATTERY, ) ] } From 7d526825c441fa43ec651aa710ed3d633a263ee5 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 11:25:43 -0400 Subject: [PATCH 19/30] fixing units for volume --- custom_components/petlibro/devices/fountains/fountain.py | 6 ++---- custom_components/petlibro/sensor.py | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index a7ca304..b7e80da 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -2,10 +2,8 @@ from . import Device UNITS = { - 1: "cup", - 2: "oz", - 3: "g", - 4: "mL" + 1: "ml", + 2: "oz" } class Fountain(Device): diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 94c5d95..168487a 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -54,9 +54,7 @@ def unit_of_measurement_fountain(device: Fountain) -> str | None: return device.unit_type def device_class_fountain(device: Fountain) -> SensorDeviceClass | None: - if device.unit_type in [UnitOfMass.OUNCES, UnitOfMass.GRAMS]: - return SensorDeviceClass.WEIGHT - if device.unit_type in ["cup", UnitOfVolume.MILLILITERS]: + if device.unit_type in ["ml", UnitOfVolume.MILLILITERS]: return SensorDeviceClass.VOLUME From 9899d191844e4a4e37833dfe149b056a1f5f9da1 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 11:38:32 -0400 Subject: [PATCH 20/30] fixing stuff --- .../petlibro/devices/fountains/fountain.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index b7e80da..8492356 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -6,6 +6,11 @@ 2: "oz" } +UNITS_RATIO = { + 1: 1, + 2: 0.35 +} + class Fountain(Device): async def refresh(self): await super().refresh() @@ -29,4 +34,12 @@ def unit_type(self) -> str | None: return unit def convert_unit(self, value: int) -> int: - return value \ No newline at end of file + """ + Convert a value to the device unit + + :param unit: Value to convert + :return: Converted value or unchanged if no unit + """ + if self.unit_id: + return value * UNITS_RATIO.get(self.unit_id, 1) + return value \ No newline at end of file From 8155ed3078171df98acf292d6772b2f662c79df6 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 11:45:46 -0400 Subject: [PATCH 21/30] fixed unit converstion --- custom_components/petlibro/devices/fountains/fountain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 8492356..3f4baa5 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -8,7 +8,7 @@ UNITS_RATIO = { 1: 1, - 2: 0.35 + 2: 0.034 } class Fountain(Device): From 36223f97748aebab77d5f7e4b08308589b7b49f3 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 12:00:34 -0400 Subject: [PATCH 22/30] changed device types --- custom_components/petlibro/sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 168487a..2b5d17b 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -144,13 +144,13 @@ def device_class(self) -> SensorDeviceClass | None: native_unit_of_measurement_fn=unit_of_measurement_fountain, device_class_fn=device_class_fountain, device_class=SensorDeviceClass.VOLUME, - state_class=SensorStateClass.TOTAL_INCREASING + state_class=SensorStateClass.MEASUREMENT ), PetLibroSensorEntityDescription[DockstreamFountain]( key="weight_percent", translation_key="weight_percent", icon="mdi:percent", - device_class=SensorDeviceClass.BATTERY, + device_class=SensorDeviceClass.MOISTURE, ) ] } From bd5ce3885bc6b9756cabd242946fdec384ea192b Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 12:05:22 -0400 Subject: [PATCH 23/30] adding %, I think --- custom_components/petlibro/sensor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 2b5d17b..23ab209 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -150,6 +150,7 @@ def device_class(self) -> SensorDeviceClass | None: key="weight_percent", translation_key="weight_percent", icon="mdi:percent", + unit_of_measurement="%", device_class=SensorDeviceClass.MOISTURE, ) ] From 2a1e33ebd2c7e340cc3df556fd4f58600e06a174 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 12:13:55 -0400 Subject: [PATCH 24/30] Trying to get the % label to show --- custom_components/petlibro/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 23ab209..ed632ae 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -150,7 +150,7 @@ def device_class(self) -> SensorDeviceClass | None: key="weight_percent", translation_key="weight_percent", icon="mdi:percent", - unit_of_measurement="%", + native_unit_of_measurement="%", device_class=SensorDeviceClass.MOISTURE, ) ] From 482268c117defeb0b59d2284315fdbafeb05dbc4 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 15:27:29 -0400 Subject: [PATCH 25/30] trying to refresh water data correctly --- .../petlibro/devices/fountains/dockstream_fountain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py index 51ca65f..68f85de 100644 --- a/custom_components/petlibro/devices/fountains/dockstream_fountain.py +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -7,7 +7,7 @@ class DockstreamFountain(Fountain): async def refresh(self): await super().refresh() self.update_data({ - "grainStatus": await self.api.device_grain_status(self.serial) + "realInfo": await self.api.device_grain_status(self.serial) }) @property From 6b7d51fc93071926674c91449f0b5da9d9e6b5f0 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 15:54:07 -0400 Subject: [PATCH 26/30] attempt to get fountain to refresh --- .../petlibro/devices/fountains/dockstream_fountain.py | 2 +- custom_components/petlibro/devices/fountains/fountain.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py index 68f85de..2f512ac 100644 --- a/custom_components/petlibro/devices/fountains/dockstream_fountain.py +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -7,7 +7,7 @@ class DockstreamFountain(Fountain): async def refresh(self): await super().refresh() self.update_data({ - "realInfo": await self.api.device_grain_status(self.serial) + "realInfo": await self.api.device_real_info(self.serial) }) @property diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 3f4baa5..168116a 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -14,9 +14,9 @@ class Fountain(Device): async def refresh(self): await super().refresh() - self.update_data({ - "feedingPlanTodayNew": await self.api.device_feeding_plan_today_new(self.serial) - }) + #self.update_data({ + # "feedingPlanTodayNew": await self.api.device_feeding_plan_today_new(self.serial) + #}) @property def unit_id(self) -> int | None: From ca8bebbd1d52a4d768bf7756ea015416a485f430 Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 16:23:07 -0400 Subject: [PATCH 27/30] still trying to get it to regresh --- .../petlibro/devices/fountains/dockstream_fountain.py | 4 +--- custom_components/petlibro/devices/fountains/fountain.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py index 2f512ac..8925a88 100644 --- a/custom_components/petlibro/devices/fountains/dockstream_fountain.py +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -6,9 +6,7 @@ class DockstreamFountain(Fountain): async def refresh(self): await super().refresh() - self.update_data({ - "realInfo": await self.api.device_real_info(self.serial) - }) + @property def remaining_cleaning(self) -> str: diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 168116a..69ebc96 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -14,9 +14,7 @@ class Fountain(Device): async def refresh(self): await super().refresh() - #self.update_data({ - # "feedingPlanTodayNew": await self.api.device_feeding_plan_today_new(self.serial) - #}) + @property def unit_id(self) -> int | None: From f8fc15468dca2ed2bc8d65cb4f8abc43e9c5989f Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 17:01:34 -0400 Subject: [PATCH 28/30] reducing timeout for refresh --- custom_components/petlibro/hub.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 3573620..d9b987c 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -17,7 +17,7 @@ from .devices import Device, product_name_map, product_id_map _LOGGER = getLogger(__name__) -UPDATE_INTERVAL_SECONDS = 60 * 5 +UPDATE_INTERVAL_SECONDS = 60 * 2 class PetLibroHub: @@ -37,6 +37,7 @@ def __init__(self, hass: HomeAssistant, data: Mapping[str, Any]) -> None: name=DOMAIN, update_method=self.refresh_devices, update_interval=timedelta(seconds=UPDATE_INTERVAL_SECONDS), + ) async def get_device(self, serial: str) -> Optional[Device]: From 9b701582665c99ff5c0c1f3a0b9cf7564614200f Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Mon, 30 Sep 2024 08:03:27 -0400 Subject: [PATCH 29/30] reducing timeout for refresh attempting to add fountain support adding sensors for fountain fixed sensor class adding weight percent added labels for water fixing labels trying to get the water today to show up trying a device class fixing units for volume fixing stuff fixed unit converstion changed device types adding %, I think Trying to get the % label to show trying to refresh water data correctly attempt to get fountain to refresh still trying to get it to regresh --- .../petlibro/devices/__init__.py | 4 +- .../devices/fountains/dockstream_fountain.py | 29 ++++++++++++++ .../petlibro/devices/fountains/fountain.py | 40 ++++++++++++++++++- custom_components/petlibro/hub.py | 5 ++- custom_components/petlibro/sensor.py | 38 ++++++++++++++++++ .../petlibro/translations/en.json | 19 +++++++++ 6 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 custom_components/petlibro/devices/fountains/dockstream_fountain.py diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 1719d5c..2558216 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -2,6 +2,7 @@ from .device import Device from .feeders.granary_feeder import GranaryFeeder from .feeders.granary_camera_feeder import GranaryCameraFeeder +from .fountains.dockstream_fountain import DockstreamFountain product_name_map : Dict[str, Type[Device]] = { "Granary Feeder": GranaryFeeder, @@ -10,5 +11,6 @@ product_id_map : Dict[str, Type[Device]] = { "PLAF103": GranaryFeeder, - "PLAF203": GranaryCameraFeeder + "PLAF203": GranaryCameraFeeder, + "PLWF105": DockstreamFountain, } diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py new file mode 100644 index 0000000..8925a88 --- /dev/null +++ b/custom_components/petlibro/devices/fountains/dockstream_fountain.py @@ -0,0 +1,29 @@ +from typing import cast + +from .fountain import Fountain + + +class DockstreamFountain(Fountain): + async def refresh(self): + await super().refresh() + + + @property + def remaining_cleaning(self) -> str: + return cast(str, self._data.get("remainingCleaningDays")) + + @property + def remaining_replacement_days(self) -> str: + return cast(str, self._data.get("remainingReplacementDays")) + + @property + def today_totalMl(self) -> int: + quantity = self._data.get("todayTotalMl") + if not quantity: + return 0 + + return self.convert_unit(quantity) + + @property + def weight_percent(self) -> int: + return cast(int, self._data.get("weightPercent")) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 8f952c1..69ebc96 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -1,5 +1,43 @@ +from typing import Optional, cast from . import Device +UNITS = { + 1: "ml", + 2: "oz" +} + +UNITS_RATIO = { + 1: 1, + 2: 0.034 +} class Fountain(Device): - pass + async def refresh(self): + await super().refresh() + + + @property + def unit_id(self) -> int | None: + """The device unit type identifier""" + return self._data.get("unitType") + + @property + def unit_type(self) -> str | None: + """The device unit type""" + unit : Optional[str] = None + + if unit_id := self.unit_id: + unit = UNITS.get(unit_id) + + return unit + + def convert_unit(self, value: int) -> int: + """ + Convert a value to the device unit + + :param unit: Value to convert + :return: Converted value or unchanged if no unit + """ + if self.unit_id: + return value * UNITS_RATIO.get(self.unit_id, 1) + return value \ No newline at end of file diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index 23835f5..d9b987c 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -17,7 +17,7 @@ from .devices import Device, product_name_map, product_id_map _LOGGER = getLogger(__name__) -UPDATE_INTERVAL_SECONDS = 60 * 5 +UPDATE_INTERVAL_SECONDS = 60 * 2 class PetLibroHub: @@ -37,6 +37,7 @@ def __init__(self, hass: HomeAssistant, data: Mapping[str, Any]) -> None: name=DOMAIN, update_method=self.refresh_devices, update_interval=timedelta(seconds=UPDATE_INTERVAL_SECONDS), + ) async def get_device(self, serial: str) -> Optional[Device]: @@ -57,7 +58,7 @@ async def load_devices(self): await device.refresh() # Get all API data self.devices.append(device) else: - _LOGGER.error("Unsupported device found: %s", device_data["productIdentifier"]) + _LOGGER.info("Unsupported device found: %s", device_data["productIdentifier"]) async def refresh_devices(self) -> bool: """Update all known devices states from the PETLIBRO API.""" diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index 6f9058b..ed632ae 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -19,6 +19,8 @@ from .devices import Device from .devices.feeders.feeder import Feeder from .devices.feeders.granary_feeder import GranaryFeeder +from .devices.fountains.fountain import Fountain +from .devices.fountains.dockstream_fountain import DockstreamFountain from . import PetLibroHubConfigEntry from .entity import PetLibroEntity, _DeviceT, PetLibroEntityDescription @@ -46,6 +48,14 @@ def device_class_feeder(device: Feeder) -> SensorDeviceClass | None: return SensorDeviceClass.WEIGHT if device.unit_type in ["cup", UnitOfVolume.MILLILITERS]: return SensorDeviceClass.VOLUME + + +def unit_of_measurement_fountain(device: Fountain) -> str | None: + return device.unit_type + +def device_class_fountain(device: Fountain) -> SensorDeviceClass | None: + if device.unit_type in ["ml", UnitOfVolume.MILLILITERS]: + return SensorDeviceClass.VOLUME @dataclass(frozen=True) @@ -115,6 +125,34 @@ def device_class(self) -> SensorDeviceClass | None: icon="mdi:history", state_class=SensorStateClass.TOTAL_INCREASING ) + ], + DockstreamFountain: [ + PetLibroSensorEntityDescription[DockstreamFountain]( + key="remaining_cleaning", + translation_key="remaining_cleaning", + icon="mdi:calendar-clock" + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="remaining_replacement_days", + translation_key="remaining_replacement_days", + icon="mdi:calendar-clock" + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="today_totalMl", + translation_key="today_totalMl", + icon="mdi:water", + native_unit_of_measurement_fn=unit_of_measurement_fountain, + device_class_fn=device_class_fountain, + device_class=SensorDeviceClass.VOLUME, + state_class=SensorStateClass.MEASUREMENT + ), + PetLibroSensorEntityDescription[DockstreamFountain]( + key="weight_percent", + translation_key="weight_percent", + icon="mdi:percent", + native_unit_of_measurement="%", + device_class=SensorDeviceClass.MOISTURE, + ) ] } diff --git a/custom_components/petlibro/translations/en.json b/custom_components/petlibro/translations/en.json index 37d5715..f458756 100644 --- a/custom_components/petlibro/translations/en.json +++ b/custom_components/petlibro/translations/en.json @@ -35,7 +35,26 @@ }, "today_feeding_times": { "name": "Today's feeding times" + }, + "today_water_quantity": { + "name": "Today's water quantity" + }, + "today_water_times": { + "name": "Today's water times" + }, + "remaining_cleaning": { + "name": "Cleaning remaining days" + }, + "remaining_replacement_days": { + "name": "Filter remaining days" + }, + "weight_percent": { + "name": "Water Remaining" + }, + "today_totalMl": { + "name": "Today's total water" } + }, "switch": { "feeding_plan": { From 2533bbcfef89ed70dabdcc84ba46e26e3691b23a Mon Sep 17 00:00:00 2001 From: Jeremy Brown Date: Fri, 4 Oct 2024 17:56:59 -0400 Subject: [PATCH 30/30] Revert "reducing timeout for refresh" This reverts commit 9b701582665c99ff5c0c1f3a0b9cf7564614200f. --- .../petlibro/devices/__init__.py | 4 +- .../devices/fountains/dockstream_fountain.py | 29 -------------- .../petlibro/devices/fountains/fountain.py | 40 +------------------ custom_components/petlibro/hub.py | 5 +-- custom_components/petlibro/sensor.py | 38 ------------------ .../petlibro/translations/en.json | 19 --------- 6 files changed, 4 insertions(+), 131 deletions(-) delete mode 100644 custom_components/petlibro/devices/fountains/dockstream_fountain.py diff --git a/custom_components/petlibro/devices/__init__.py b/custom_components/petlibro/devices/__init__.py index 2558216..1719d5c 100644 --- a/custom_components/petlibro/devices/__init__.py +++ b/custom_components/petlibro/devices/__init__.py @@ -2,7 +2,6 @@ from .device import Device from .feeders.granary_feeder import GranaryFeeder from .feeders.granary_camera_feeder import GranaryCameraFeeder -from .fountains.dockstream_fountain import DockstreamFountain product_name_map : Dict[str, Type[Device]] = { "Granary Feeder": GranaryFeeder, @@ -11,6 +10,5 @@ product_id_map : Dict[str, Type[Device]] = { "PLAF103": GranaryFeeder, - "PLAF203": GranaryCameraFeeder, - "PLWF105": DockstreamFountain, + "PLAF203": GranaryCameraFeeder } diff --git a/custom_components/petlibro/devices/fountains/dockstream_fountain.py b/custom_components/petlibro/devices/fountains/dockstream_fountain.py deleted file mode 100644 index 8925a88..0000000 --- a/custom_components/petlibro/devices/fountains/dockstream_fountain.py +++ /dev/null @@ -1,29 +0,0 @@ -from typing import cast - -from .fountain import Fountain - - -class DockstreamFountain(Fountain): - async def refresh(self): - await super().refresh() - - - @property - def remaining_cleaning(self) -> str: - return cast(str, self._data.get("remainingCleaningDays")) - - @property - def remaining_replacement_days(self) -> str: - return cast(str, self._data.get("remainingReplacementDays")) - - @property - def today_totalMl(self) -> int: - quantity = self._data.get("todayTotalMl") - if not quantity: - return 0 - - return self.convert_unit(quantity) - - @property - def weight_percent(self) -> int: - return cast(int, self._data.get("weightPercent")) diff --git a/custom_components/petlibro/devices/fountains/fountain.py b/custom_components/petlibro/devices/fountains/fountain.py index 69ebc96..8f952c1 100644 --- a/custom_components/petlibro/devices/fountains/fountain.py +++ b/custom_components/petlibro/devices/fountains/fountain.py @@ -1,43 +1,5 @@ -from typing import Optional, cast from . import Device -UNITS = { - 1: "ml", - 2: "oz" -} - -UNITS_RATIO = { - 1: 1, - 2: 0.034 -} class Fountain(Device): - async def refresh(self): - await super().refresh() - - - @property - def unit_id(self) -> int | None: - """The device unit type identifier""" - return self._data.get("unitType") - - @property - def unit_type(self) -> str | None: - """The device unit type""" - unit : Optional[str] = None - - if unit_id := self.unit_id: - unit = UNITS.get(unit_id) - - return unit - - def convert_unit(self, value: int) -> int: - """ - Convert a value to the device unit - - :param unit: Value to convert - :return: Converted value or unchanged if no unit - """ - if self.unit_id: - return value * UNITS_RATIO.get(self.unit_id, 1) - return value \ No newline at end of file + pass diff --git a/custom_components/petlibro/hub.py b/custom_components/petlibro/hub.py index d9b987c..23835f5 100644 --- a/custom_components/petlibro/hub.py +++ b/custom_components/petlibro/hub.py @@ -17,7 +17,7 @@ from .devices import Device, product_name_map, product_id_map _LOGGER = getLogger(__name__) -UPDATE_INTERVAL_SECONDS = 60 * 2 +UPDATE_INTERVAL_SECONDS = 60 * 5 class PetLibroHub: @@ -37,7 +37,6 @@ def __init__(self, hass: HomeAssistant, data: Mapping[str, Any]) -> None: name=DOMAIN, update_method=self.refresh_devices, update_interval=timedelta(seconds=UPDATE_INTERVAL_SECONDS), - ) async def get_device(self, serial: str) -> Optional[Device]: @@ -58,7 +57,7 @@ async def load_devices(self): await device.refresh() # Get all API data self.devices.append(device) else: - _LOGGER.info("Unsupported device found: %s", device_data["productIdentifier"]) + _LOGGER.error("Unsupported device found: %s", device_data["productIdentifier"]) async def refresh_devices(self) -> bool: """Update all known devices states from the PETLIBRO API.""" diff --git a/custom_components/petlibro/sensor.py b/custom_components/petlibro/sensor.py index ed632ae..6f9058b 100644 --- a/custom_components/petlibro/sensor.py +++ b/custom_components/petlibro/sensor.py @@ -19,8 +19,6 @@ from .devices import Device from .devices.feeders.feeder import Feeder from .devices.feeders.granary_feeder import GranaryFeeder -from .devices.fountains.fountain import Fountain -from .devices.fountains.dockstream_fountain import DockstreamFountain from . import PetLibroHubConfigEntry from .entity import PetLibroEntity, _DeviceT, PetLibroEntityDescription @@ -48,14 +46,6 @@ def device_class_feeder(device: Feeder) -> SensorDeviceClass | None: return SensorDeviceClass.WEIGHT if device.unit_type in ["cup", UnitOfVolume.MILLILITERS]: return SensorDeviceClass.VOLUME - - -def unit_of_measurement_fountain(device: Fountain) -> str | None: - return device.unit_type - -def device_class_fountain(device: Fountain) -> SensorDeviceClass | None: - if device.unit_type in ["ml", UnitOfVolume.MILLILITERS]: - return SensorDeviceClass.VOLUME @dataclass(frozen=True) @@ -125,34 +115,6 @@ def device_class(self) -> SensorDeviceClass | None: icon="mdi:history", state_class=SensorStateClass.TOTAL_INCREASING ) - ], - DockstreamFountain: [ - PetLibroSensorEntityDescription[DockstreamFountain]( - key="remaining_cleaning", - translation_key="remaining_cleaning", - icon="mdi:calendar-clock" - ), - PetLibroSensorEntityDescription[DockstreamFountain]( - key="remaining_replacement_days", - translation_key="remaining_replacement_days", - icon="mdi:calendar-clock" - ), - PetLibroSensorEntityDescription[DockstreamFountain]( - key="today_totalMl", - translation_key="today_totalMl", - icon="mdi:water", - native_unit_of_measurement_fn=unit_of_measurement_fountain, - device_class_fn=device_class_fountain, - device_class=SensorDeviceClass.VOLUME, - state_class=SensorStateClass.MEASUREMENT - ), - PetLibroSensorEntityDescription[DockstreamFountain]( - key="weight_percent", - translation_key="weight_percent", - icon="mdi:percent", - native_unit_of_measurement="%", - device_class=SensorDeviceClass.MOISTURE, - ) ] } diff --git a/custom_components/petlibro/translations/en.json b/custom_components/petlibro/translations/en.json index f458756..37d5715 100644 --- a/custom_components/petlibro/translations/en.json +++ b/custom_components/petlibro/translations/en.json @@ -35,26 +35,7 @@ }, "today_feeding_times": { "name": "Today's feeding times" - }, - "today_water_quantity": { - "name": "Today's water quantity" - }, - "today_water_times": { - "name": "Today's water times" - }, - "remaining_cleaning": { - "name": "Cleaning remaining days" - }, - "remaining_replacement_days": { - "name": "Filter remaining days" - }, - "weight_percent": { - "name": "Water Remaining" - }, - "today_totalMl": { - "name": "Today's total water" } - }, "switch": { "feeding_plan": {