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

[BUG] Validating device automation trigger payloads #3528

Open
ckm2k1 opened this issue Nov 20, 2024 · 0 comments
Open

[BUG] Validating device automation trigger payloads #3528

ckm2k1 opened this issue Nov 20, 2024 · 0 comments
Labels
enhancement Improve an existing quirk no stale Bot won't close issue/PR even if inactive

Comments

@ckm2k1
Copy link
Contributor

ckm2k1 commented Nov 20, 2024

Bug description

Based on this PR: #3504

The source of the bug in that PR is that the trigger payload was using an Enum member rather than a type supported by Voluptuous. Since this is an easy mistake to make, and the impact is that it breaks all automations for a given quirk or device, it feels valuable to add some guardrails to this flow.

Here's a couple of ideas for improving the devx:

  • Write a unit test that checks trigger payloads and errors when the type would not be supported by Voluptuous.
  • Write code that would automatically coerce trigger payloads into a valid type supported by Voluptuous, where such a type can be confidently determined at load/run time.

FWIW, there seems to be something similar being done for cluster command arguments via a method called schema_type_to_vol.

cc @TheJulianJES

Steps to reproduce

Create a device automation trigger and use an Enum value in the args field of the payload. (An enum inheriting from zigpy.types.enum8 would do, for example)

Expected behavior

It should fail a test or be automatically coerced into a valid type for Voluptuous.

Screenshots/Video

No response

Device signature

No response

Diagnostic information

No response

Logs

No response

Additional information

No response

@TheJulianJES TheJulianJES added enhancement Improve an existing quirk no stale Bot won't close issue/PR even if inactive labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve an existing quirk no stale Bot won't close issue/PR even if inactive
Projects
None yet
Development

No branches or pull requests

2 participants