MariusRumpf / node-lifx

Node.js implementation of the LIFX LAN protocol :bulb:
MIT License
144 stars 28 forks source link

Create event for state changed of bulb #50

Open RobinBol opened 7 years ago

RobinBol commented 7 years ago

It would be great if node-lifx could emit an event when a user changes the state of a light using the mobile app for example. Right now this is not possible as far as I know. I know polling could be used but that is rather undesired.

I have tried to cook up something myself, however I could not really read the incoming traffic and check whether the needed information was actually broadcasted.

RobinBol commented 7 years ago

It seems the iOS app does receive broadcasts from the bulb when I change its state externally, so all properties as color, temperature, onoff, seem to be broadcasted. If the library could pick this up and emit events that would be great.

MariusRumpf commented 7 years ago

This is something not yet documented by LIFX. I read in a forum post that this is realized by polling but If you saw the broadcast events before we can have a look at these packets. In https://github.com/magicmonkey/lifxjs/pull/46 somebody wrote a new wireshark dissector which might show this package then. I have not had the time to test that yet but feel free to do so. The other question is why and when these messages are broadcasted then. I don't know of any flag settings this behavior.

I personally only own an android device which I can check then.

RobinBol commented 7 years ago

It might indeed be that the mobile app initiates the polling, of which I say the responses being send over the network from the bulb to my computer.

I did not manage to setup the wireshark lua sniff script on my mac unfortunately..