Skip to content

[BUG] Validating device automation trigger payloads #3528

Open
@ckm2k1

Description

@ckm2k1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove an existing quirkno staleBot won't close issue/PR even if inactivepossible bugPossible bug, yet to be confirmed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions