Cereal2nd / velbus-aio

Velbus Asyncio
Apache License 2.0
14 stars 10 forks source link

Add EdgeLit functions #80

Closed wlcrs closed 1 year ago

wlcrs commented 1 year ago

This PR adds the ability to set the edge colors on the VMBEL1, VMBEL2, VMBEL4, VMBELO modules. I only own a VMBELO module, so I could only test against that one.

The function parameters mirror the available configuration options ins VelbusLink:

image

I used the following code to test:

velbus = Velbus(connect_str)
await velbus.connect()

# get edge lit channel
edge_lit_chan : EdgeLit = None

for key, chan in (velbus.get_module(128).get_channels()).items():
    if isinstance(chan, EdgeLit):
        edge_lit_chan = chan
        break

print(edge_lit_chan)

from velbusaio.messages.edge_set_color import CustomColorPriority
await edge_lit_chan.set_color(20, priority=CustomColorPriority.HIGH_PRIORITY, blinking=True)

await asyncio.sleep(5)

await edge_lit_chan.reset_color()
await asyncio.sleep(5)

Note that I didn't use commandRegistry.get_command(0xD4, ... to retrieve the message class, as both EdgeSetCustomColor and SetEdgeColorMessage use the same 0xD4 command code. I guess that the module itself differentiates between both by looking at the length of the message? 🤔

Cereal2nd commented 1 year ago

Thanks for this addition!

wlcrs commented 1 year ago

I'm now writing new service calls for HA integration to expose this functionality. Just mentioning this to prevent anyone from doing duplicate effort.