Skip to content

Commit

Permalink
Add manufacturer, serial_number and firmware_version to HVAC at…
Browse files Browse the repository at this point in the history
…tributes
  • Loading branch information
jasujm committed Jan 26, 2024
1 parent 049dd35 commit c12c8be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Unreleased
----------

Added
* ``manufacturer``, ``serial_number`` and ``firmware_version`` attributes to
HVAC devices

Version 0.4
-----------

Expand Down
3 changes: 3 additions & 0 deletions pyupgw/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def _parse_hvac_devices(data):


_SHADOW_TO_ATTRIBUTES_MAP: list[tuple[str, str, Callable[[typing.Any], typing.Any]]] = [
("serial_number", "ep1:sPowerMS:RadSerialNum", str),
("manufacturer", "ep1:sBasicS:ManufactureName", str),
("firmware_version", "ep1:sZDO:FirmwareVersion", str),
("target_temperature", "ep1:sTherS:HeatingSetpoint_x100", lambda v: float(v) / 100),
(
"current_temperature",
Expand Down
23 changes: 23 additions & 0 deletions pyupgw/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Models and data structures used by the library"""

# pylint: disable=too-many-instance-attributes

import enum
import functools
import logging
Expand Down Expand Up @@ -66,6 +68,15 @@ class HvacAttributes(DeviceAttributes):

type: typing.Literal[DeviceType.HVAC]

manufacturer: str | None = field(default=None)
"""Device manufacturer"""

serial_number: str | None = field(default=None)
"""Serial number"""

firmware_version: str | None = field(default=None)
"""Firmware version"""

system_mode: SystemMode | None = field(default=None)
"""The system mode (state) of the device"""

Expand Down Expand Up @@ -200,6 +211,18 @@ def unsubscribe(self, callback: DeviceChangeSubscriber):
class HvacDevice(Device[HvacAttributes]):
"""A HVAC device (smart thermostat)"""

def get_serial_number(self) -> str | None:
"""Get serial number"""
return self._attributes.serial_number

def get_manufacturer(self) -> str | None:
"""Get serial number"""
return self._attributes.manufacturer

def get_firmware_version(self) -> str | None:
"""Get serial number"""
return self._attributes.firmware_version

def get_system_mode(self) -> SystemMode | None:
"""Get mode of the device"""
return self._attributes.system_mode
Expand Down
3 changes: 3 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def test_device(attributes: HvacAttributes):
assert device.get_device_code() == attributes.device_code
assert device.get_model() == attributes.model
assert device.get_name() == attributes.name
assert device.get_serial_number() == attributes.serial_number
assert device.get_manufacturer() == attributes.manufacturer
assert device.get_firmware_version() == attributes.firmware_version
assert device.get_system_mode() == attributes.system_mode
assert device.get_running_state() == attributes.running_state
assert device.get_target_temperature() == attributes.target_temperature
Expand Down

0 comments on commit c12c8be

Please sign in to comment.