Skip to content

Commit

Permalink
Add memo text support
Browse files Browse the repository at this point in the history
  • Loading branch information
cereal2nd committed Aug 22, 2021
1 parent 2ed6185 commit 09ea850
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions velbusaio/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,22 @@ class EdgeLit(Channel):
class Memo(Channel):
"""
A Memo text
HASS OK
"""

async def set(self, txt: str) -> None:
cls = commandRegistry.get_command(0xAC, self._module.get_type())
msg = cls(self._address)
msgcntr = 0
for char in txt:
msg.memo_text += char
if len(msg.memo_text) >= 5:
msgcntr += 5
await self._writer(msg)
msg = cls(self._address)
msg.start = msgcntr
await self._writer(msg)


# _mode = None
# _target = None
Expand Down
4 changes: 4 additions & 0 deletions velbusaio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
VOLUME_CUBIC_METER_HOUR: Final = "m3/h" # Not an official constant at HA yet
VOLUME_LITERS: Final = "L"
VOLUME_LITERS_HOUR: Final = "L/h" # Not an official constant at HA yet

CHANNEL_EDGE_LIT: Final = 97
CHANNEL_MEMO_TEXT: Final = 98
CHANNEL_LIGHT_VALUE: Final = 99
11 changes: 9 additions & 2 deletions velbusaio/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Temperature,
ThermostatChannel,
)
from velbusaio.const import PRIORITY_LOW
from velbusaio.const import CHANNEL_LIGHT_VALUE, CHANNEL_MEMO_TEXT, PRIORITY_LOW
from velbusaio.helpers import get_cache_dir, handle_match, keys_exists
from velbusaio.messages.blind_status import BlindStatusMessage, BlindStatusNgMessage
from velbusaio.messages.channel_name_part1 import (
Expand Down Expand Up @@ -263,7 +263,9 @@ async def on_message(self, message) -> None:
}
)
elif isinstance(message, ModuleStatusPirMessage):
await self._channels[99].update({"cur": message.light_value})
await self._channels[CHANNEL_LIGHT_VALUE].update(
{"cur": message.light_value}
)
elif isinstance(message, UpdateLedStatusMessage):
for channel in self._channels.keys():
channel = self._translate_channel_name(message.channel)
Expand Down Expand Up @@ -367,6 +369,11 @@ def number_of_channels(self) -> int:
return 0
return max(self._channels.keys())

async def set_memo_text(self, txt: str) -> None:
if CHANNEL_MEMO_TEXT not in self._channels.keys():
return
await self._channels[CHANNEL_MEMO_TEXT].set(txt)

async def _process_memory_data_message(self, message) -> None:
addr = "{high:02X}{low:02X}".format(
high=message.high_address, low=message.low_address
Expand Down

0 comments on commit 09ea850

Please sign in to comment.