Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for xy control #25

Merged
merged 12 commits into from
Oct 18, 2024
Merged

Add support for xy control #25

merged 12 commits into from
Oct 18, 2024

Conversation

DieKautz
Copy link

@DieKautz DieKautz commented Jun 26, 2024

This PR adds

  1. functionality to support fixtures with the xy color mode. It also adds the colorsource control as it is required to switch between temp, rgb and xy color control (see here).
  2. Also while using demo.py I found that BLEDevice.metadata is deprecated and therefore replaced the call as suggested here

Known Limitations

  • As colorsource is an additional control, the consumer (casambi-bt-hass) needs to set this property correctly. (Add support for xy color control casambi-bt-hass#84)
  • In a different PR I saw that methods in Casambi are used as helpers, e.g. for setting temperature to directly change the attribute of a Unit or Group. How would the exact OpCode and binary format be found? Wireshark?

@lkempf
Copy link
Owner

lkempf commented Jul 13, 2024

Sorry that this took so long. I'm having a look now. To get the missing information you either have to look at the debug messages generated by the library (which dumps all decrypted packages) or use frida to get logs from the app. But I'll see what I can do regarding your questions.

@lkempf
Copy link
Owner

lkempf commented Jul 13, 2024

Where did you get the 11 bits from that you use for the XY resolution? I've changed your code to get the length from the unit control but I used the 11 bits for the SetColorXY operation. The resolution in UnitState was only needed because I decided against using floats for some reason.

@lkempf
Copy link
Owner

lkempf commented Jul 13, 2024

Thanks for the contribution. Looks good to me now (pending a decision on the 11 bit default). Can you easily test my changes? I don't have a fixture available that supports xy or colorsource.

@DieKautz
Copy link
Author

Hi, thank you for putting your time in!

From my side this can be merged 👍

@lkempf lkempf changed the base branch from main to dev September 25, 2024 16:25
@lkempf lkempf changed the base branch from dev to main September 25, 2024 16:44
@lkempf lkempf changed the base branch from main to dev September 25, 2024 16:45
@lkempf
Copy link
Owner

lkempf commented Sep 25, 2024

Sorry for the mess (and the wait). The color conversion should be fixed now. Could you test it again?

@DieKautz
Copy link
Author

I just was able to test it again. Seems to be working just fine now. Thank you for your help!
LGTM

@lkempf lkempf merged commit a9c6d0e into lkempf:dev Oct 18, 2024
1 check passed
lkempf added a commit that referenced this pull request Nov 5, 2024
* Replace use of deprecated BLEDevice.metadata

* Add unitstate fields for colorsource and xy color

* Switch to float representation of xy_color

* Readd missing colorsource setter

* Typing fix

* Implement SetColorXY operation

* Fix linter

* Switch to using control length for xy parsing

* Use an enum for colorsource

* Export ColorSource

* Attempt to fix bug in conversion from bytes to state for XY

* Sort imports

---------

Co-authored-by: Lukas Kempf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants