Lua scripts as action in scenes

I just found some more examples here and this one does work to turn on a “Switch”

require "core"
local items = core.get_items()
if items then
    for _, item in ipairs(items) do
        if item.name == "switch" and item.device_id == "<Device-ID-Here>" then
            core.set_item_value(item.id, true)
        end
    end
end

You have to use the device ID not the item ID of the switch component of that device.