Skip to content

ValidationError: MotionSensor fails setup when batteryPercentage is missing #175

@JoeWanne475

Description

@JoeWanne475

Hi,

I’m running Home Assistant with the custom integration dirigera_platform.
During setup the integration fails with a Pydantic ValidationError when at least
one motion sensor does not report attributes.batteryPercentage.

Stacktrace excerpt:

pydantic_core._pydantic_core.ValidationError: 1 validation error for MotionSensor
attributes.batteryPercentage
Field required [type=missing]

The IKEA Dirigera hub returns a valid motion sensor object, but without
batteryPercentage in attributes. This causes the entire config entry setup
to fail.

Observed behavior:

  • Integration setup aborts completely
  • No devices are created
  • Happens consistently with a specific motion sensor

Expected behavior:

  • batteryPercentage should be optional
  • Integration should tolerate missing battery values and continue setup

Additional notes:

  • The affected device is visible in the IKEA Smart Home app
  • Firmware is up to date

I believe should define batteryPercentage as optional
(e.g. int | None = None) to avoid hard failures on incomplete device payloads.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions