Hi @cokeman, thank you very much for all the testing!
Nice that it works reliably now.
In the long (private) PM thread, you mentioned that the plugin is usually fast, but slow from time to time, especially when changing the state fast.
Both appearances of slowness are probably caused by the fact that openLuup does not use multiple threads, but one large event-loop to handle everything. Most of the time that is idle, so a device change will immediately be handled. The polling of Tradfri devices is one of the things that happens once every x seconds during this loop. As far as I know, but maybe @akbooer can correct me, it is not possible to run a timed task as real thread, outside of the main loop, with openLuup.
In your case, with many devices that are polled regularly, polling of all devices may take that long that you notice it either on the UI, or by the response of the device itself. In addition, the Tradfri gateway sometimes does not respond - I don’t know why - and this happens more frequently when the gateway is hit with load of requests. And this is what is done with every poll iteration.
There are two mitigations as far as I see:
- Use observe instead of poll; this removes the need for the blocking poll. The downside is that observe used to loose the connection to the Tradfri gateway eventually. This might however be improved with all the memory (leak) fixes.
- Wait until the plugin works in Vera. Vera actually does use threads for scheduled jobs, which means polling does not block other actions. Unfortunatey I have not succeeded in building my coap library for Vera yet.
Regarding support for Tradfri Groups:
I have not spend any time at implementing groups yet, but I think a basic implementation is trivial.
The reason I did not so far is that I considered Vera to be the main controller. Devices, such as lamps are therefore primarily controlled by Vera. To control multiple bulbs at once, you would typically use a scene (or, preferred by me, Reactor). This scenario would for example support combining Tradfri & other bulbs.
So a group could be modeled as a scene. That would allow representing the links between the devices that are controlled by the group. The features of a group however will be severely limited when it is modeled as a scene.
The most basic implementation is to represent a group by switch.
In the IKEA app, besides switching on/off, a group can also control the brightness and color (or both, as a preset represented by a ‘mood’). This means a group is best represented as an RGB bulb and each mood as a separate RGB bulb as well.
Any suggestions or other ideas?