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

#2388 Implement color sync #2441

Merged
merged 14 commits into from
May 16, 2021
Merged

#2388 Implement color sync #2441

merged 14 commits into from
May 16, 2021

Conversation

sjorge
Copy link
Sponsor Contributor

@sjorge sjorge commented Apr 2, 2021

  • rebase after Move common operations on colors to lib/color.js #2453
  • ColorXY.toRGB()
    • implement
    • unit test
  • syncColorState
    • implement
    • call in toZigbee.light_colortemp
    • call in toZigbee.light_color
    • call in fromZigbee.color_colortemp
    • cleanup toZigbee. light_color_colortemp
  • scenes
    • set color_mode in scene_add
    • call syncColorState in scene_recall ?
  • testing

@sjorge sjorge force-pushed the color_sync branch 2 times, most recently from a0413ca to 25881c5 Compare April 2, 2021 19:20
converters/fromZigbee.js Outdated Show resolved Hide resolved
converters/fromZigbee.js Outdated Show resolved Hide resolved
@sjorge sjorge force-pushed the color_sync branch 2 times, most recently from 03d7ae8 to 2f531c4 Compare April 4, 2021 10:15
@sjorge

This comment has been minimized.

@blazewicz
Copy link
Contributor

@sjorge you may want to check my PR #2453. Your changes could be done on top of mine, I already added few tests for lib/light.js

@sjorge

This comment has been minimized.

@sjorge sjorge force-pushed the color_sync branch 5 times, most recently from 9644d9a to 7786695 Compare April 4, 2021 12:02
@sjorge

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2021

This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@sjorge

This comment has been minimized.

@sjorge sjorge force-pushed the color_sync branch 7 times, most recently from 035255a to 3863ef2 Compare May 8, 2021 11:27
@sjorge

This comment has been minimized.

@Koenkk
Copy link
Owner

Koenkk commented May 8, 2021

@sjorge for xy -> mireds no lookup is used but a function:

const n = (this.x - 0.3320) / (0.1858 - this.y);

* From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
* @return {ColorRGB}
*/
toRGB() {
Copy link
Sponsor Contributor Author

@sjorge sjorge May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blazewicz can you have another look at this, going from XY -> RGB I'm not getting the expected red/green/blues, they all seem off a bit and have negative values too which definitely doesn't seem right.

Also why the tests are failing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converters/toZigbee.js Outdated Show resolved Hide resolved
converters/toZigbee.js Outdated Show resolved Hide resolved
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented May 12, 2021

@Koenkk excellent! Even hue support reading all attributes at ones, I can't find my osram bulb though :(

Zigbee2MQTT:debug 2021-05-12 20:41:08: Received Zigbee message from '0x0017880104259333', type 'readResponse', cluster 'lightingColorCtrl', data '{"colorMode":2,"colorTemperature":370,"currentSaturation":143,"currentX":30107,"currentY":26897,"enhancedCurrentHue":8382}' from endpoint 11 with groupID 0

Osram also OK:

Zigbee2MQTT:debug 2021-05-12 21:01:55: Received Zigbee message from '0xf0d1b8000010b893', type 'readResponse', cluster 'lightingColorCtrl', data '{"colorMode":2,"colorTemperature":454,"currentSaturation":254,"currentX":45914,"currentY":19615,"enhancedCurrentHue":22016}' from endpoint 1 with groupID 0

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented May 12, 2021

Aside from the currently unresolved issues with ColorXY.toRGB() it seems to be working for a groups too, assuming that bulbs/groups have the same color_sync value of true.

image

converters/toZigbee.js Outdated Show resolved Hide resolved
recalledState = addColorMode(recalledState);
}

// XXX: meta.state is the groups state, we are leaking group state TO devices!
Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Koenkk with this it works, but see the XXX comment.
There has to be a clean way of doing it. This is the last remaining issue together with the toRGB() issue

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjorge wasn't this the case already before? I don't understand how to color_sync causes this.

@sjorge

This comment has been minimized.

lib/color.js Outdated Show resolved Hide resolved
lib/color.js Show resolved Hide resolved
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented May 14, 2021

@blazewicz Ah nice, yeah I did notice the numbers were super close without the reverse correction, so I guess it was indeed not needed like I first though.!

@Koenkk just one small issue remaining now: scene_recall is leaking state from group -> member device which is not good at all.

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented May 15, 2021 via email

lib/color.js Outdated Show resolved Hide resolved
@Koenkk
Copy link
Owner

Koenkk commented May 16, 2021

@sjorge yes, found this with the z2m tests, ready to go! Big thanks as usual 🎖️

@Koenkk Koenkk merged commit f317842 into Koenkk:master May 16, 2021
@sjorge sjorge deleted the color_sync branch May 16, 2021 18:32
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.

3 participants