From 84e8fc243969d77fc02b1a02b39b5872ba6c0912 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 2 Oct 2024 18:10:52 -0400 Subject: [PATCH] Changes to PW to allow for long sensor interval. Adds various information about device. --- custom_components/phyn/devices/base.py | 3 +++ custom_components/phyn/devices/pw.py | 6 +++--- custom_components/phyn/entities/base.py | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/phyn/devices/base.py b/custom_components/phyn/devices/base.py index c5d6660..ddcf635 100644 --- a/custom_components/phyn/devices/base.py +++ b/custom_components/phyn/devices/base.py @@ -86,6 +86,9 @@ def rssi(self) -> float: def serial_number(self) -> str: """Return the serial number for the device.""" return self._device_state["serial_number"] + + async def async_setup(self): + pass async def _update_firmware_information(self, *_) -> None: self._firmware_info.update( diff --git a/custom_components/phyn/devices/pw.py b/custom_components/phyn/devices/pw.py index f39aea7..8fce235 100644 --- a/custom_components/phyn/devices/pw.py +++ b/custom_components/phyn/devices/pw.py @@ -121,9 +121,9 @@ async def async_update_data(self): async def _update_device(self, *_) -> None: """Update the device state from the API.""" to_ts = int(datetime.timestamp(datetime.now()) * 1000) - from_ts = to_ts - (3600 * 24 * 1000) + from_ts = to_ts - (3600 * 72 * 1000) data = await self._coordinator.api_client.device.get_water_statistics(self._phyn_device_id, from_ts, to_ts) - LOGGER.debug("PW1 data: %s", data) + LOGGER.debug("PW1 data (%s): %s", (self._phyn_device_id, data)) item = None for entry in data: @@ -136,7 +136,7 @@ async def _update_device(self, *_) -> None: if item: self._water_statistics.update(item) - LOGGER.debug("Phyn Water device state: %s", self._device_state) + LOGGER.debug("Phyn Water device state (%s): %s", (self._phyn_device_id, self._device_state)) async def async_setup(self): """Async setup not needed""" diff --git a/custom_components/phyn/entities/base.py b/custom_components/phyn/entities/base.py index 2e0be7d..61d24fd 100644 --- a/custom_components/phyn/entities/base.py +++ b/custom_components/phyn/entities/base.py @@ -4,6 +4,7 @@ from typing import Any from homeassistant.helpers.entity import DeviceInfo, Entity +from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, @@ -61,6 +62,8 @@ def device_info(self) -> DeviceInfo: model=self._device.model, name=self._device.device_name.capitalize(), sw_version=self._device.firmware_version, + connections={(CONNECTION_NETWORK_MAC, self._device.id)}, + serial_number=self._device.serial_number ) @property