Skip to content

Commit

Permalink
Only return categorys if the channel is enabled, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
cereal2nd committed Aug 23, 2021
1 parent 09ea850 commit cf8e761
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 25 additions & 2 deletions velbusaio/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -440,16 +448,31 @@ 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:
"""
Return if this relay is on
"""
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
Expand Down
21 changes: 16 additions & 5 deletions velbusaio/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit cf8e761

Please sign in to comment.