Skip to content

Commit

Permalink
Merge pull request #14 from msp1974/dev
Browse files Browse the repository at this point in the history
v1.5.15
  • Loading branch information
msp1974 authored Oct 9, 2024
2 parents 6f60fbe + 97e3712 commit b30e5b2
Show file tree
Hide file tree
Showing 51 changed files with 1,169 additions and 517 deletions.
Empty file modified .github/workflows/python-publish.yml
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist-issue
aioWiserHeatAPI.egg-info
venv
tests/
extra_config.json*
Empty file modified MANIFEST
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Drayton Wiser Hub API Async v1.5.14
# Drayton Wiser Hub API Async v1.5.15

This repository contains a simple API which queries the Drayton Wiser Heating sysystem used in the UK.

Expand Down Expand Up @@ -52,6 +52,12 @@ Documentation available in [info.md](https://github.com/msp1974/wiserHeatAPIv2/b

## Changelog

### v1.5.15

* Added addiitonal functions for v2 hub lights, equipments etc
* Added support for WindowDoor sensors
* Added support for Boiler Interface device

### v1.5.14

* Fix presets not using defined boost temp
Expand Down
2 changes: 1 addition & 1 deletion aioWiserHeatAPI/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
name = "aioWiserHeatAPI"
__all__ = ["wiserAPI", "wiserDiscovery"]

__VERSION__ = "1.5.14"
__VERSION__ = "1.5.15"

_LOGGER = logging.getLogger(__name__)
85 changes: 85 additions & 0 deletions aioWiserHeatAPI/automation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import inspect

from . import _LOGGER
from .const import TEXT_UNKNOWN, WISERSYSTEM
from .rest_controller import _WiserRestController


class _WiserAutomation:
def __init__(
self, wiser_rest_controller: _WiserRestController, automation_data: dict
):
self._wiser_rest_controller = wiser_rest_controller
self._automation_data = automation_data

async def _send_command(self, cmd: dict) -> bool:
"""
Send system control command to Wiser Hub
param cmd: json command structure
return: boolen - true = success, false = failed
"""
result = await self._wiser_rest_controller._send_command(WISERSYSTEM, cmd)
if result:
_LOGGER.debug(
"Wiser hub - %s command successful", format(inspect.stack()[1].function)
)
return True
return False

@property
def id(self) -> int:
return self._automation_data.get("id", 0)

@property
def name(self) -> str:
return self._automation_data.get("Name", TEXT_UNKNOWN)

@property
def enabled(self) -> bool:
return self._automation_data.get("Enabled", False)

async def trigger(self):
"""Activate automation"""
return await self._send_command({"TriggerAutomation": self.id})

@property
def notification_enabled(self) -> bool:
return self._automation_data.get("EnableNotification", False)

async def enable_notification(self):
"""Activate automation"""
return await self._send_command({"EnableNotification": self.id})


class _WiserAutomationCollection(object):
def __init__(
self, wiser_rest_controller: _WiserRestController, automations_data: dict
):
self._automation_data = automations_data
self._automations = []
self._wiser_rest_controller = wiser_rest_controller
self._build()

def _build(self):
for automation in self._automation_data:
self._automations.append(
_WiserAutomation(self._wiser_rest_controller, automation)
)

@property
def all(self) -> list[_WiserAutomation]:
"""Return list of automations"""
return self._automations

@property
def count(self) -> int:
"""Count of automations"""
return len(self._automations)

def get_by_id(self, automation_id: int) -> _WiserAutomation:
try:
return [
automation for automation in self.all if automation.id == automation_id
][0]
except IndexError:
return None
67 changes: 67 additions & 0 deletions aioWiserHeatAPI/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Handles binary_sensor devices
"""

from .helpers.battery import _WiserBattery
from .helpers.device import _WiserDevice


class _WiserBinarySensor(_WiserDevice):
"""Class representing a Wiser Binary Sensor"""

@property
def active(self) -> bool:
"""Get if is active"""
return self._device_type_data.get("Active")

@property
def interacts_with_room_climate(self) -> bool:
"""Get the if interacts with room climate"""
return self._device_type_data.get("InteractsWithRoomClimate")

@property
def type(self) -> str:
"""Get the type of device"""
return self._device_type_data.get("Type")

@property
def enable_notification(self) -> str:
"""Get if notifications is enable"""
return self._device_type_data.get("EnableNotification")

@property
def battery(self) -> _WiserBattery:
"""Get the battery information for the smokealarm"""
return _WiserBattery(self._data)


class _WiserWindowDoorSensor(_WiserBinarySensor):
"""Class representing a Wiser WindowDoor Sensor"""


class _WiserBinarySensorCollection:
"""Class holding all Wiser Binary Sensors"""

def __init__(self):
self._items = []

@property
def all(self) -> list[_WiserBinarySensor]:
return list(self._items)

@property
def count(self) -> int:
return len(self.all)

def get_by_id(self, id: int) -> _WiserBinarySensor:
"""
Gets a binarysensor object from the binary sensor id
param id: id of binary sensor
return: _WiserBinarySensor object
"""
try:
return [binarysensor for binarysensor in self.all if binarysensor.id == id][
0
]
except IndexError:
return None
40 changes: 40 additions & 0 deletions aioWiserHeatAPI/boiler_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from .helpers.device import _WiserDevice


class _WiserBoilerInterface(_WiserDevice):
"""Class representing a Wiser Boiler Interface"""

@property
def heating_channel_ids(self) -> list[int]:
"""Heating channel ids."""
return self._device_type_data.get("HeatingChannelIds")


class _WiserBoilerInterfaceCollection:
"""Class holding all Wiser Boiler Interfaces"""

def __init__(self):
self._items = []

@property
def all(self) -> list[_WiserBoilerInterface]:
return list(self._items)

@property
def count(self) -> int:
return len(self.all)

def get_by_id(self, id: int) -> _WiserBoilerInterface:
"""
Gets a boiler interface object from the binary sensor id
param id: id of boiler interface
return: _WiserBoilerInterface object
"""
try:
return [
boilerinterface
for boilerinterface in self.all
if boilerinterface.id == id
][0]
except IndexError:
return None
Empty file modified aioWiserHeatAPI/cli.py
100644 → 100755
Empty file.
35 changes: 35 additions & 0 deletions aioWiserHeatAPI/const.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
TEXT_WEEKENDS = "Weekends"
TEXT_ALL = "All"
TEXT_UNABLE = "Unable"
# added by Lgo44

TEXT_REVERSE = "ReverseWithLoad"
TEXT_CONSISTENT = "ConsistentWithLoad"
TEXT_ALWAYSON = "AlwaysOn"
TEXT_ALWAYSOFF = "AlwaysOff"

TEXT_LASTON = "LastOnBrightness"
TEXT_LEVELPERCENT = "LevelPercent"

# End added by Lgo44

# Day Value Lists
WEEKDAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
Expand Down Expand Up @@ -88,6 +99,8 @@
WISERLIGHT = "Light/{}"
WISERPOWERTAGENERGY = "PTE/{}"
WISERSMOKEALARM = "SmokeAlarmDevice/{}"
WISERBINARYSENSOR = "BinarySensor/{}"
WISERBOILERINTERFACE = "BoilerInterface/{}"


# Enums
Expand Down Expand Up @@ -116,11 +129,33 @@ class WiserShutterAwayActionEnum(enum.Enum):
nochange = TEXT_NO_CHANGE


# added by Lgo44
class WiserLightLedIndicatorEnum(enum.Enum):
reverse = TEXT_REVERSE
consistent = TEXT_CONSISTENT
allwayson = TEXT_ALWAYSON
allwaysoff = TEXT_ALWAYSOFF


class WiserLightPowerOnBehaviourEnum(enum.Enum):
last = TEXT_LASTON
levelpercent = TEXT_LEVELPERCENT


# End added by Lgo44


class WiserDeviceModeEnum(enum.Enum):
auto = TEXT_AUTO
manual = TEXT_MANUAL


class WiserHotWaterClimateModeEnum(enum.Enum):
auto = TEXT_AUTO
manual = TEXT_MANUAL
off = TEXT_OFF


class WiserHeatingModeEnum(enum.Enum):
off = TEXT_OFF
auto = TEXT_AUTO
Expand Down
Loading

0 comments on commit b30e5b2

Please sign in to comment.