milanmeu / aionanoleaf

Async typed Python package for the Nanoleaf OpenAPI
GNU Lesser General Public License v3.0
1 stars 8 forks source link

Nanoleaf events #1

Open lorond opened 3 years ago

lorond commented 3 years ago

Hello, thanks for nanoleaf HA integration!

Do you have any plans to add events support? Currently it updates via pooling and have quite a big lag. Also Canvas touch events are not supported at all.

https://forum.nanoleaf.me/docs#_l9kelug0qi5s

3.5. Events Developers can register and listen to events from Nanoleaf Devices using Server-Sent Events (SSE).

3.5.2. Events Types Event Type Event Type Id
State: 1
Layout 2
Effects 3
Touch: 4

3.5.2.4.2. Touch Stream Data

As of firmware version 1.4.0+, clients will be able to optionally register for fine resolution, low latency, touch data stream from the canvas controller over a UDP socket, if the client has also registered for Touch Events.

daveismith commented 2 years ago

I was looking into this before integrating my nanoleaf elements. You can see in nanoleaf.py there's a listen_events function which uses the event functionality. When you look at the init.py file in the home assistant integration it calls listen_events.

There is a bit of lag from an event to the update of Home Assistant, but I observed this based on the time it takes for the nanoleaf device to send out the update vs the actual event happening.

I would suggest that this issue could be closed.

milanmeu commented 2 years ago

Event support has been added in version 0.1.0. I've already done some work on supporting touch events via a UDP socket, and this should be added to the library by the end of February.

velaar commented 2 years ago

Hello @milanmeu , thank you for your hard work! I wonder if the homeassistant implementation of touch events through device triggers is being limited by this library. Especially as we can't at the moment process device triggers on a per-tile basis.

Is there a particular reason why we don't have a tile ID in the output for touch events?