Unihiker button

From espressif/esp-claw-skills-lab · View interactive version

Unihiker button is an AI agent skill from the GitHub repository espressif/esp-claw-skills-lab. Use this skill when the user asks to read UNIHIKER K10 A/B button status, wait for button press, or detect button events from the XL9535 IO expander.

How to use this skill

Skill file

UNIHIKER Button (XL9535)

Use this skill when the user asks to read UNIHIKER K10 A/B button status, wait for button press, or detect button events from the XL9535 IO expander.

Typical user requests include:

Chinese aliases that should map to this skill include: 行空板 K10 按键、A 键、B 键、按键中断、按键事件监听。

Hardware mapping for this skill:

The script provides two main modes:

Run exactly one bundled Lua script with lua_run_script.

If script execution returns an error, report that error directly to the user.

Do not retry with changed arguments in the same turn unless the user explicitly asks.

Script Args Schema

{
  "type": "object",
  "properties": {
    "mode": {
      "type": "string",
      "enum": ["read", "wait_event"]
    },
    "target": {
      "type": "string",
      "enum": ["a", "b", "any"]
    },
    "edge": {
      "type": "string",
      "enum": ["press", "release", "any"]
    },
    "active_level": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1
    },
    "timeout_ms": {
      "type": "integer",
      "minimum": 0,
      "maximum": 120000
    },
    "poll_interval_ms": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "debounce_ms": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "i2c_port": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1
    },
    "sda": {
      "type": "integer",
      "minimum": 0,
      "maximum": 63
    },
    "scl": {
      "type": "integer",
      "minimum": 0,
      "maximum": 63
    },
    "i2c_freq_hz": {
      "type": "integer",
      "minimum": 10000,
      "maximum": 1000000
    },
    "addr": {
      "type": "integer",
      "minimum": 8,
      "maximum": 119
    }
  }
}

Tool Call Inputs

Read current A/B button states once:

{"path":"{CUR_SKILL_DIR}/scripts/unihiker_button.lua","args":{"mode":"read"}}

Wait up to 10 seconds for any button press/release event:

{"path":"{CUR_SKILL_DIR}/scripts/unihiker_button.lua","args":{"mode":"wait_event","target":"any","edge":"any","timeout_ms":10000}}

Wait only for A button press:

{"path":"{CUR_SKILL_DIR}/scripts/unihiker_button.lua","args":{"mode":"wait_event","target":"a","edge":"press","timeout_ms":10000}}

Recommended Flow

  1. Confirm XL9535 is connected on the expected I2C bus and address (0x20 by default).
  2. For reactive logic, prefer wait_event instead of periodic app-side polling.
  3. Use small poll_interval_ms (for example 1 to 5) and suitable debounce_ms (for example 8 to 20) for stable button events.
  4. Run {CUR_SKILL_DIR}/scripts/unihiker_button.lua.
  5. Report script output directly to the user.

执行超时

args.timeout_ms 是按键等待时长,与工具超时不同。默认短等待使用 lua_run_script;较长等待需给工具设置更大的正数超时,或改用 lua_run_script_async,指定稳定名称 unihiker_button、exclusive: "unihiker_button"、replace: false。脚本的等待时长最多 120000 ms,args.timeout_ms: 0 表示不持续等待;不要把它误当作异步任务的无限运行超时,也不要给同步工具传 timeout_ms: 0。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.