Light Switch
Apps & Automationlight_switchLight Switch is an Agent Skill for apps & automation published in the espressif/esp-claw repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Turn a board light on or off, set LED strip color or brightness, and control GPIO lights. Requires board_hardware_info skill.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/espressif/esp-claw/blob/HEAD/application/edge_agent/fatfs_image/storage/skills/light_switch/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/light-switch, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Light Switch
Use this skill when the user asks to turn a board light on or off, change an LED strip color, or adjust light brightness.
Run exactly one script with lua_run_script after reading board_hardware_info.
You MUST pass args when using lua_run_script to control the light, as specified in the input schema shown below in the section LED Strip Script Args Schema and GPIO Light Script Args Schema.
If lua_run_script returns an error, report that error directly to the user.
Do not retry, change arguments, or run another light script in the same turn unless the user explicitly asks.
LED Strip Script Args Schema
{
"type": "object",
"properties": {
"io": {
"type": "integer",
"default": 38,
"minimum": 0
},
"led_count": {
"type": "integer",
"default": 1,
"minimum": 1
},
"enabled": {
"type": "boolean",
"default": true
},
"brightness": {
"type": "integer",
"default": 255,
"minimum": 0,
"maximum": 255
},
"color": {
"type": "object",
"properties": {
"r": {
"type": "integer",
"default": 255,
"minimum": 0,
"maximum": 255
},
"g": {
"type": "integer",
"default": 255,
"minimum": 0,
"maximum": 255
},
"b": {
"type": "integer",
"default": 255,
"minimum": 0,
"maximum": 255
}
}
}
}
}
GPIO Light Script Args Schema
{
"type": "object",
"properties": {
"io": {
"type": "integer",
"default": 38,
"minimum": 0
},
"enabled": {
"type": "boolean",
"default": true
},
"active_level": {
"type": "integer",
"default": 1,
"minimum": 0,
"maximum": 1
},
"brightness": {
"type": "integer",
"default": 255,
"minimum": 0,
"maximum": 255
}
}
}
GPIO lights are binary. Ignore color for GPIO lights. Treat brightness: 0 as off and any non-zero brightness as on.
LED Strip Tool Call Inputs
Use args as the JSON object shown below.
Turn off:
{"path":"{CUR_SKILL_DIR}/scripts/led_strip_switch.lua","args":{"enabled":false}}
Turn on white:
{"path":"{CUR_SKILL_DIR}/scripts/led_strip_switch.lua","args":{"enabled":true}}
Set red at half brightness:
{"path":"{CUR_SKILL_DIR}/scripts/led_strip_switch.lua","args":{"enabled":true,"brightness":128,"color":{"r":255,"g":0,"b":0}}}
Set all pixels in a 3-pixel LED strip to red at half brightness:
{"path":"{CUR_SKILL_DIR}/scripts/led_strip_switch.lua","args":{"io":46,"led_count":3,"enabled":true,"brightness":128,"color":{"r":255,"g":0,"b":0}}}
GPIO Light Tool Call Inputs
Turn off an active-high GPIO light:
{"path":"{CUR_SKILL_DIR}/scripts/gpio_light_switch.lua","args":{"io":23,"enabled":false,"active_level":1}}
Turn on an active-low GPIO light:
{"path":"{CUR_SKILL_DIR}/scripts/gpio_light_switch.lua","args":{"io":43,"enabled":true,"active_level":0}}
Recommended Flow
- Activate the
board_hardware_infoskill and query the board hardware info before operating hardware. - Use the
Device Inventoryheadings and occupied IO lines fromboard_hardware_info; do not guess pins outside that skill. - Prefer an
led_stripdevice when present. Use its occupied IO, typically the referenced RMT TXgpioline, asio. - Use
max_ledsfrom hardware info asled_countwhen available; otherwise keep the defaultled_count: 1. - If no
led_stripdevice exists, look for a GPIO light by device name, such asflashlight,led_*,*_led, or names containinglight. - If
chip: gpio_ledortype: gpio_ctrlis visible in hardware info, treat that as a GPIO light signal when the name also indicates a light. - For GPIO lights, use the GPIO from the device occupied IO such as
gpioorpin. - Use
active_levelfrom hardware info when available. If explicit active-high or active-low text is visible, map it to1or0. - If no active-level information is available, use the script default
active_level: 1and do not claim active-low behavior. - Do not use the default
iovalue ifboard_hardware_infoprovides one. - For LED strips, run
{CUR_SKILL_DIR}/scripts/led_strip_switch.luawith the resolvedio,led_count, and any requested color or brightness. - For GPIO lights, run
{CUR_SKILL_DIR}/scripts/gpio_light_switch.luawith the resolvedio,active_level, and requested enabled state. - For GPIO lights, ignore color and map
brightness: 0to off. - If neither LED strip nor GPIO light hardware is listed, inform the user that the board does not declare a controllable light and stop.
- Report the result or error directly to the user.