async def test_turn_on_fan_without_speed(hass: core.HomeAssistant): """Tests that turn on command delegates to turn on API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_turn_on, patch_bond_device_state(): await turn_fan_on(hass, "fan.name_1") mock_turn_on.assert_called_with("test-device-id", Action.turn_on())
async def async_turn_on( self, percentage: int | None = None, preset_mode: str | None = None, **kwargs: Any, ) -> None: """Turn on the fan.""" _LOGGER.debug("Fan async_turn_on called with percentage %s", percentage) if preset_mode is not None: await self.async_set_preset_mode(preset_mode) elif percentage is not None: await self.async_set_percentage(percentage) else: await self._hub.bond.action(self._device.device_id, Action.turn_on())
async def test_turn_on_switch(hass: core.HomeAssistant): """Tests that turn on 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_on, patch_bond_device_state(): await hass.services.async_call( SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "switch.name_1"}, blocking=True, ) await hass.async_block_till_done() mock_turn_on.assert_called_once_with("test-device-id", Action.turn_on())
async def test_turn_on_fireplace_without_brightness(hass: core.HomeAssistant): """Tests that turn on command delegates to turn on API.""" await setup_platform(hass, LIGHT_DOMAIN, fireplace("name-1"), bond_device_id="test-device-id") with patch_bond_action() as mock_turn_on, patch_bond_device_state(): await hass.services.async_call( LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: "light.name_1"}, blocking=True, ) await hass.async_block_till_done() mock_turn_on.assert_called_once_with("test-device-id", Action.turn_on())
flame = state.get("flame") self._attr_is_on = power == 1 self._attr_brightness = round(flame * 255 / 100) if flame else None self._attr_icon = "mdi:fireplace" if power == 1 else "mdi:fireplace-off" async def async_turn_on(self, **kwargs: Any) -> None: """Turn the fireplace on.""" _LOGGER.debug("Fireplace async_turn_on called with: %s", kwargs) if brightness := kwargs.get(ATTR_BRIGHTNESS): flame = round((brightness * 100) / 255) await self._hub.bond.action(self._device.device_id, Action.set_flame(flame)) else: await self._hub.bond.action(self._device.device_id, Action.turn_on()) 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_set_brightness_belief(self, brightness: int) -> None: """Set the belief state of the light.""" if not self._device.supports_set_brightness(): raise HomeAssistantError( "This device does not support setting brightness") if brightness == 0: await self.async_set_power_belief(False) return
async def async_turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" await self._hub.bond.action(self._device.device_id, Action.turn_on())