async def async_set_power_belief(self, power_state: bool) -> None: """Set the belief state of the light.""" try: await self._hub.bond.action( self._device.device_id, Action.set_light_state_belief(power_state)) except ClientResponseError as ex: raise HomeAssistantError( f"The bond API returned an error calling set_light_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex
async def test_light_set_power_belief(hass: core.HomeAssistant): """Tests that the set brightness belief function of a light delegates to API.""" await setup_platform( hass, LIGHT_DOMAIN, light("name-1"), bond_device_id="test-device-id", ) with patch_bond_action() as mock_bond_action, patch_bond_device_state(): await hass.services.async_call( DOMAIN, SERVICE_SET_LIGHT_POWER_TRACKED_STATE, { ATTR_ENTITY_ID: "light.name_1", ATTR_POWER_STATE: False }, blocking=True, ) await hass.async_block_till_done() mock_bond_action.assert_called_once_with( "test-device-id", Action.set_light_state_belief(False))