Danimal4326 / homebridge-ecoplug

Homebridge plugin for the Eco Plug
MIT License
30 stars 15 forks source link

Added eco device auto discovery during startup #2

Closed NorthernMan54 closed 7 years ago

NorthernMan54 commented 7 years ago

Hi,

This is a first draft of an attempt of implementing device auto discovery, as I really dislike editing config files. I also split the eco specific code into a separate library to make it easier to maintain and follow the homebridge flows.

I would suggest trying this out for a few days before publishing as the production version.

For the device auto discovery, the app is just broadcasting a message of 128 bytes, with a 6 byte value starting at byte 24. On the first try it didn't seem to care about what the value was so I hard coded it. Will need to watch this and see what happens over time.

When I parsed out the discovery response packet, I couldn't find a device model field. As I have outlets and wall switches, I thought it would be useful map this to the appropriate home kit device.

On my roadmap of further changes will be looking into status polling, and look into either implementing a polling routine, or determining if the device broadcasts changes. When looking at the network sniffer the device is very chatty, so it may be sending updates.

Also on the roadmap will be updating the device auto discovery to discovery devices at any time, and not just at startup. I have this already working in a different plugin, so will be straight forward to port. The plugin with this is homebridge-mcuiot.