-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from msp1974/dev
v1.5.15
- Loading branch information
Showing
51 changed files
with
1,169 additions
and
517 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ dist-issue | |
aioWiserHeatAPI.egg-info | ||
venv | ||
tests/ | ||
extra_config.json* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.