async def handle_set_manual_control(service_call: ServiceCall):
        """Set or unset lights as 'manually controlled'."""
        data = service_call.data
        _LOGGER.debug(
            "Called 'adaptive_lighting.set_manual_control' service with '%s'",
            data,
        )
        switches = _switches_from_service_call(hass, service_call)
        lights = data[CONF_LIGHTS]
        for switch in switches:
            if not lights:
                all_lights = switch.lights
            else:
                all_lights = _expand_light_groups(hass, lights)
            if service_call.data[CONF_MANUAL_CONTROL]:
                for light in all_lights:
                    _fire_manual_control_event(switch, light, service_call.context)
            else:
                switch.manager.reset(*all_lights)
                if switch.is_on:
                    context = switch.create_context(
                        "service",
                        parent=service_call.context,
                    )
                    # pylint: disable=protected-access
                    await switch._update_attrs_and_maybe_adapt_lights(
                        context=context,
                        lights=all_lights,
                        transition=switch.initial_transition,
                        force=True,
                    )
Set or unset lights as 'manually controlled'.
custom_components/adaptive_lighting/switch.py