pixoo icon indicating copy to clipboard operation
pixoo copied to clipboard

[FR] Automatic device discovery based on DeviceID/DeviceMAC

Open fonix232 opened this issue 2 years ago • 3 comments

I'm considering writing a Home Assistant wrapper for this library at the moment. One of the harder challenges to do is the "wandering IP" - without setting up a fixed IP address (for which I'd need to use my router, as the Divoom app and API do not support any such network settings), when the device reconnects, it will get a new IP via DHCP.

This means that a HA integration instance cannot be based on the IP address alone.

For this purpose it would be great if the library offered a way to resolve a Pixoo class instance by supplying the DeviceID/DeviceMAC (which does not change), and using the https://app.divoom-gz.com/Device/ReturnSameLANDevice endpoint to get the actual IP address.

fonix232 avatar Jan 11 '23 17:01 fonix232

Hi,

check out my fork/pull request: https://github.com/SomethingWithComputers/pixoo/pull/13

thanks for the information :)

Pfleiderer-Adrian avatar Jan 11 '23 21:01 Pfleiderer-Adrian

Looks good on first blink - although I'd probably move the address resolution logic to a completely separate method, as to simplify __init__.

You might also want to rename the address parameter to something more matching, since now it's become address/macaddress/deviceid in one. Maybe connectionString? Or something similar?

fonix232 avatar Jan 13 '23 12:01 fonix232

Hi, thank you for your feedback. You are right, the init function should be simplified. You can check my new commit. There are also a new function: __get_url_from_connection_string :)

Pfleiderer-Adrian avatar Jan 13 '23 13:01 Pfleiderer-Adrian

With the refactored code, this is not currently super needed, but I will look into including something like this for the next release!

SomethingWithComputers avatar Aug 18 '24 17:08 SomethingWithComputers