Skip to content

Commit

Permalink
Enable push updates for socket protocol (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Apr 16, 2022
1 parent a1c6038 commit 666b79c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions flux_led/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,16 @@ def construct_device_config(


class ProtocolLEDENETSocket(ProtocolLEDENET8Byte):
@property
def power_push_updates(self) -> bool:
"""If True the protocol pushes power state updates when controlled via ir/rf/app."""
return True

@property
def state_push_updates(self) -> bool:
"""If True the protocol pushes state updates when controlled via ir/rf/app."""
return True

@property
def name(self) -> str:
"""The name of the protocol."""
Expand Down
23 changes: 23 additions & 0 deletions tests_aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,29 @@ def _updated_callback(*args, **kwargs):
assert str(timers[3]) == "[ON ] 17:48 SuMoTuWeThFrSa "


@pytest.mark.asyncio
async def test_sockets_push_updates(
mock_aio_protocol, caplog: pytest.LogCaptureFixture
):
"""Test we can get the timers."""
socket = AIOWifiLedBulb("192.168.1.166")

def _updated_callback(*args, **kwargs):
pass

task = asyncio.create_task(socket.async_setup(_updated_callback))
transport, protocol = await mock_aio_protocol()
socket._aio_protocol.data_received(
b"\x81\x97\x23\x61\x05\x10\xb6\x00\x98\x19\x04\x25\x0f\x50"
)
socket._aio_protocol.data_received(b"\xf0\x32\xf0\xf0\xf0\xf0\xe2")

await task
assert socket.model_num == 0x97
assert socket._protocol.power_push_updates is True
assert socket._protocol.state_push_updates is True


@pytest.mark.asyncio
async def test_async_get_timers_8_byte_device(
mock_aio_protocol, caplog: pytest.LogCaptureFixture
Expand Down

0 comments on commit 666b79c

Please sign in to comment.