async def async_set_power_belief(self, power_state: bool) -> None: """Set the believed state to on or off.""" try: await self._hub.bond.action( self._device.device_id, Action.set_power_state_belief(power_state) ) except ClientResponseError as ex: raise HomeAssistantError( f"The bond API returned an error calling set_power_state_belief for {self.entity_id}. Code: {ex.code} Message: {ex.message}" ) from ex
async def test_set_speed_belief_speed_100(hass: core.HomeAssistant): """Tests that set power belief service delegates to API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_action, patch_bond_device_state(): await hass.services.async_call( BOND_DOMAIN, SERVICE_SET_FAN_SPEED_TRACKED_STATE, {ATTR_ENTITY_ID: "fan.name_1", "speed": 100}, blocking=True, ) await hass.async_block_till_done() mock_action.assert_any_call("test-device-id", Action.set_power_state_belief(True)) mock_action.assert_called_with("test-device-id", Action.set_speed_belief(3))
async def test_switch_set_power_belief(hass: core.HomeAssistant): """Tests that the set power belief service delegates to API.""" await setup_platform( hass, SWITCH_DOMAIN, generic_device("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( BOND_DOMAIN, SERVICE_SET_POWER_TRACKED_STATE, {ATTR_ENTITY_ID: "switch.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_power_state_belief(False) )
async def test_fp_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, fireplace_with_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_power_state_belief(False))