async def async_turn_off(self, **kwargs: Any) -> None: """Turn the fan off.""" if self.preset_mode == PRESET_MODE_BREEZE: await self._hub.bond.action( self._device.device_id, Action(Action.BREEZE_OFF) ) await self._hub.bond.action(self._device.device_id, Action.turn_off())
async def test_turn_on_fan_with_off_percentage(hass: core.HomeAssistant): """Tests that turn off command delegates to turn off API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_turn_off, patch_bond_device_state(): await turn_fan_on(hass, "fan.name_1", percentage=0) mock_turn_off.assert_called_with("test-device-id", Action.turn_off())
async def test_turn_off_switch(hass: core.HomeAssistant): """Tests that turn off command 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_turn_off, patch_bond_device_state(): await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "switch.name_1"}, blocking=True, ) await hass.async_block_till_done() mock_turn_off.assert_called_once_with("test-device-id", Action.turn_off())
async def test_set_speed_off(hass: core.HomeAssistant): """Tests that set_speed(off) command delegates to turn off API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_turn_off, patch_bond_device_state(): await hass.services.async_call( FAN_DOMAIN, SERVICE_SET_PERCENTAGE, service_data={ATTR_ENTITY_ID: "fan.name_1", ATTR_PERCENTAGE: 0}, blocking=True, ) await hass.async_block_till_done() mock_turn_off.assert_called_with("test-device-id", Action.turn_off())
async def test_turn_on_fan_with_off_with_breeze(hass: core.HomeAssistant): """Tests that turn off command delegates to turn off API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan_with_breeze("name-1"), bond_device_id="test-device-id", state={"breeze": [1, 0, 0]}, ) assert (hass.states.get("fan.name_1").attributes[ATTR_PRESET_MODE] == PRESET_MODE_BREEZE) with patch_bond_action() as mock_actions, patch_bond_device_state(): await turn_fan_on(hass, "fan.name_1", percentage=0) assert mock_actions.mock_calls == [ call("test-device-id", Action(Action.BREEZE_OFF)), call("test-device-id", Action.turn_off()), ]
async def async_turn_off(self, **kwargs: Any) -> None: """Turn the fireplace off.""" _LOGGER.debug("Fireplace async_turn_off called with: %s", kwargs) await self._hub.bond.action(self._device.device_id, Action.turn_off())
async def async_turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" await self._hub.bond.action(self._device.device_id, Action.turn_off())