From cf8e761f37d6b09a0338be36c1409799f25baa61 Mon Sep 17 00:00:00 2001 From: cereal2nd Date: Mon, 23 Aug 2021 13:37:46 +0200 Subject: [PATCH] Only return categorys if the channel is enabled, bump version --- setup.py | 2 +- velbusaio/channels.py | 27 +++++++++++++++++++++++++-- velbusaio/module.py | 21 ++++++++++++++++----- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index cc209ca..385d2b0 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="velbus-aio", - version="2021.8.10", + version="2021.8.11", url="https://github.com/Cereal2nd/velbus-aio", license="MIT", author="Maikel Punie", diff --git a/velbusaio/channels.py b/velbusaio/channels.py index c5874ba..66df91d 100644 --- a/velbusaio/channels.py +++ b/velbusaio/channels.py @@ -212,7 +212,9 @@ class Button(Channel): _led_state = None def get_categories(self) -> list: - return ["binary_sensor", "led"] + if self._enabled: + return ["binary_sensor", "led"] + return [] def is_closed(self) -> bool: """ @@ -390,6 +392,12 @@ def get_state(self) -> int: def is_temperature(self) -> bool: return True + def get_max(self) -> int: + return round(self._max, 2) + + def get_min(self) -> int: + return round(self._min, 2) + class SensorNumber(Channel): """ @@ -440,9 +448,15 @@ class Relay(Channel): """ _on = None + _enabled = True + _inhibit = False + _forced_on = False + _disabled = False def get_categories(self) -> list: - return ["switch"] + if self._enabled: + return ["switch"] + return [] def is_on(self) -> bool: """ @@ -450,6 +464,15 @@ def is_on(self) -> bool: """ return self._on + def is_inhibit(self) -> bool: + return self._inhibit + + def is_forced_on(self) -> bool: + return self._forced_on + + def is_disabled(self) -> bool: + return self._disabled + async def turn_on(self) -> None: """ Send the turn on message diff --git a/velbusaio/module.py b/velbusaio/module.py index 589454f..18f768f 100644 --- a/velbusaio/module.py +++ b/velbusaio/module.py @@ -208,7 +208,14 @@ async def on_message(self, message) -> None: elif isinstance(message, MemoryDataMessage): await self._process_memory_data_message(message) elif isinstance(message, RelayStatusMessage): - await self._channels[message.channel].update({"on": message.is_on()}) + await self._channels[message.channel].update( + { + "on": message.is_on(), + "inhibit": message.is_inhibited(), + "forced_on": message.is_forced_on(), + "disabled": message.is_disabled(), + } + ) elif isinstance(message, SensorTemperatureMessage): chan = self._translate_channel_name(self._data["TemperatureChannel"]) await self._channels[chan].update( @@ -222,10 +229,14 @@ async def on_message(self, message) -> None: # update the current temp chan = self._translate_channel_name(self._data["TemperatureChannel"]) if chan in self._channels: - await self._channels[chan].update({"cur": message.current_temp}) - # self._target = message.target_temp - # self._cmode = message.mode_str - # self._cstatus = message.status_str + await self._channels[chan].update( + { + "cur": message.current_temp, + "target": message.target_temp, + "cmode": message.mode_str, + "cstatus": message.status_str, + } + ) elif isinstance(message, PushButtonStatusMessage): for channel in message.closed: channel = self._translate_channel_name(channel)