Skip to content

Commit

Permalink
Changes to PW to allow for long sensor interval. Adds various informa…
Browse files Browse the repository at this point in the history
…tion about device.
  • Loading branch information
jordanruthe committed Oct 2, 2024
1 parent a55009a commit 84e8fc2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions custom_components/phyn/devices/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions custom_components/phyn/devices/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"""
Expand Down
3 changes: 3 additions & 0 deletions custom_components/phyn/entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84e8fc2

Please sign in to comment.