Skip to content

Validate light supported_color_modes#48247

Closed
emontnemery wants to merge 1 commit into
home-assistant:devfrom
emontnemery:light_validate_supported_color_modes
Closed

Validate light supported_color_modes#48247
emontnemery wants to merge 1 commit into
home-assistant:devfrom
emontnemery:light_validate_supported_color_modes

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

Proposed change

Validate light supported_color_modes and print a warning if the validation failed

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

)
except vol.Error as ex:
_LOGGER.warning("Light %s: %s", self.entity_id, ex)
supported_color_modes = {COLOR_MODE_ONOFF}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of this, should the state update be rejected?

supported_color_modes
)
except vol.Error as ex:
_LOGGER.warning("Light %s: %s", self.entity_id, ex)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This may spam a lot, should the warning be limited to once per entity?

)
supported_color_modes = self._light_internal_supported_color_modes
try:
supported_color_modes = validate_supported_color_modes(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't validate attributes at runtime as it can get too costly to do it for everything. Instead I once had this idea #37663

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In this particular case, it's a capability attribute which should rarely change, if ever.
If the attribute has not changed, there's no need to re-validate.

In #37663 it's mentioned that:

It's up to each integration to implement a validator platform.

So it's opt-in per integration? Can't it be done in base components instead?

@emontnemery
Copy link
Copy Markdown
Contributor Author

Closed in favor of #48836

@emontnemery emontnemery closed this Apr 8, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants