tagyoureit / homebridge-luxor

Homebridge plugin for Luxor FX lights
6 stars 6 forks source link

Generate Unique Serial Numbers #17

Closed ahodges9 closed 2 years ago

ahodges9 commented 2 years ago

It's currently not possible to leverage this plugin with Home Assistant as it requires unique serial numbers for each entity. It would be great if this plugin would generate unique serial numbers using some combination of the MAC address and group id. This would allow all the entities to be imported into Home Assistant

tagyoureit commented 2 years ago

I'm not real familiar with HA. But this plugin creates a unique UUID for each accessory. What exactly would be needed to make it work with HA?

ahodges9 commented 2 years ago

It looks like it's just a matter of setting the SerialNumber of all the accessories you expose, currently they are all the "DefaultSerial". For ZD_Lights.js it would just be a matter of setting the this.platform.Characteristic.SerialNumber characteristic to the UUID you generate:

this.accessory.getService(this.platform.Service.AccessoryInformation)
     .setCharacteristic(this.platform.Characteristic.Manufacturer, "Luxor")
     .setCharacteristic(this.platform.Characteristic.Model, this.context.type)
     .setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.UUID)

I am not sure how the UUID is generated, but these should ideally be persistent across reboots of HomeBridge and the Luxor controller.

For HomeAssistant, I also needed to up the timeout to get a reliable connection as I would see sometime my controller would randomly take 3-5 seconds to respond. This results in the entities in HomeAssistant showing as unavailable even though you could still control them. I'm sure not everyone has this issue, but it would be great if the timeout was in the config file so I didn't need to make code changes.

tagyoureit commented 2 years ago

Pull the latest 4.2.0. I added both the serial number and also you can change the http timeout in the config.

The timeout issues have been a challenge. If I send commands too fast to the Luxor controller some commands are ignored/rejected. There might be a DoS or at least limiter on the number of api calls that can be sent at the same time. If I make the timeouts too long Homebridge will complain that the device is non-responsive.

ahodges9 commented 2 years ago

Nice, I do see all the lights coming up with 4.2.0! It still looks to have issues with the scenes as those don't get unique serials, but I don't use those as all my themes are in HomeAssistant. Ideally, I could just exclude all themes similar to how you can exclude the groups but not a huge issue.

Thanks a lot!

tagyoureit commented 2 years ago

D'oh! I just pushed up 4.2.1. It has the serial number for the themes so you at least won't get errors.

ahodges9 commented 2 years ago

Perfect! Thanks for the quick turnaround!