Skip to content

Conversation

@SoulSniper1212
Copy link

Overview

This PR fixes an issue where Home Assistant would reject device discovery due to conflicting color_mode and supported_color_modes fields in the discovery payload. When both fields are present, Home Assistant treats it as an error. The fix ensures that the deprecated color_mode field is removed when supported_color_modes is present.

Checklist

  • Code changes are complete
  • Tests pass
  • Documentation updated (if applicable)

Proof that changes are correct

The fix is a simple conditional check that removes the color_mode field when supported_color_modes is present in the payload. This prevents the conflict that was causing Home Assistant to reject the discovery. The change is backwards compatible as it only removes the deprecated field in cases where the preferred field is present.

Signed-off-by: SoulSniper1212 <warush23@gmail.com>
// Ensure deprecated color_mode field is not present when supported_color_modes is used
// This prevents Home Assistant from rejecting the discovery due to conflicting fields
if (payload.supported_color_modes && payload.color_mode === true) {
delete payload.color_mode;
Copy link
Owner

Choose a reason for hiding this comment

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

color_mode has been removed a long time ago already, I also don't see any color_mode properties being added in this file. Could you provide the debug log when z2m discovers a device with color_mode?

See this on how to enable debug logging.

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