home-assistant/core · error · HomeAssistantError

The bond API returned an error calling set_power_state_belie

Error message

The bond API returned an error calling set_power_state_belief for {self.entity_id}.  Code: {ex.status}  Message: {ex.message}

What it means

Raised by BondFan.async_set_power_belief in the Bond integration when the bond API action Action.set_power_state_belief(device_id, on/off) fails with an aiohttp ClientResponseError. The HomeAssistantError message embeds the HTTP status code and body message so the failure surfaces in the UI and automations.

Source

Thrown at homeassistant/components/bond/fan.py:139

        bond_speed = math.ceil(
            percentage_to_ranged_value(self._speed_range, percentage)
        )
        _LOGGER.debug(
            "async_set_percentage converted percentage %s to bond speed %s",
            percentage,
            bond_speed,
        )

        await self._bond.action(self._device_id, Action.set_speed(bond_speed))

    async def async_set_power_belief(self, power_state: bool) -> None:
        """Set the believed state to on or off."""
        try:
            await self._bond.action(
                self._device_id, Action.set_power_state_belief(power_state)
            )
        except ClientResponseError as ex:
            raise HomeAssistantError(
                "The bond API returned an error calling set_power_state_belief for"
                f" {self.entity_id}.  Code: {ex.status}  Message: {ex.message}"
            ) from ex

    async def async_set_speed_belief(self, speed: int) -> None:
        """Set the believed speed for the fan."""
        _LOGGER.debug("async_set_speed_belief called with percentage %s", speed)
        if speed == 0:
            await self.async_set_power_belief(False)
            return

        await self.async_set_power_belief(True)

        bond_speed = math.ceil(percentage_to_ranged_value(self._speed_range, speed))
        _LOGGER.debug(
            "async_set_percentage converted percentage %s to bond speed %s",
            speed,
            bond_speed,

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Check the Code: value — 401 means re-enter the access token (re-authenticate the integration); 404 means remove and re-add the device; 400 indicates the device rejects the action.
  2. Reload the Bond integration after fixing credentials or device inventory in the Bond app.
  3. Update hub firmware and the Home Assistant bond integration if 400s appear on devices that should support the action.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    await fan.async_set_power_belief(power_state)
except HomeAssistantError as err:
    if "Code: 401" in str(err):
        ...  # trigger re-auth flow
    elif "Code: 404" in str(err):
        ...  # device gone: reload / remove entity

Prevention

When it happens

Trigger: Any fan belief command (e.g. async_set_percentage with speed 0, restore-state, or turn_on/turn_off that route through power belief) while the hub returns 4xx/5xx: 401 after token rotation, 404 for a removed device_id, 400 when the device does not accept the action.

Common situations: Bond token regenerated so stored credentials went stale, device deleted from the Bond app but still present in Home Assistant, hub briefly erroring under load.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/937c4bd4baffc826. Report an issue: GitHub.