Skip to content

feat(bot): add botMode: "press" option for momentary-button behavior#1395

Open
roshun wants to merge 2 commits into
OpenWonderLabs:latestfrom
roshun:fix/bot-device-press-mode
Open

feat(bot): add botMode: "press" option for momentary-button behavior#1395
roshun wants to merge 2 commits into
OpenWonderLabs:latestfrom
roshun:fix/bot-device-press-mode

Conversation

@roshun

@roshun roshun commented Jun 29, 2026

Copy link
Copy Markdown

Summary

  • Adds an optional botMode: "press" per-device config field for Bot accessories
  • When set, tapping the tile sends a single press command (not turnOn/turnOff) and the On characteristic auto-resets to false after 1 second
  • Default behavior (botMode omitted or "switch") is unchanged

Motivation

A SwitchBot Bot used to toggle a physical momentary button (e.g. a coffee machine power button) doesn't have meaningful on/off state. Without this option, HomeKit shows the tile as a persistent toggle — the user must manually turn it off after each press, and same-accessory automations to auto-reset are blocked by HomeKit.

With botMode: "press" the tile behaves like a button: tap it, the bot presses, the tile snaps back to off automatically.

Config example

{
  "deviceId": "DE6443C6502B",
  "configDeviceName": "Espresso Machine",
  "configDeviceType": "Bot",
  "botMode": "press"
}

Implementation notes

  • BotDevice.createHAPAccessory is overridden; when botMode !== "press" it falls through to super.createHAPAccessory so existing behavior is fully preserved
  • SwitchBotHAPPlatform.registerHAPAccessories stores the HAP On characteristic on the BotDevice instance after onSet registration, so the 1-second reset timer can call characteristic.updateValue(false) without needing a platform reference
  • TypeScript compiles cleanly with tsc --noEmit

Test plan

  • Bot with no botMode set: on/off toggle works as before
  • Bot with botMode: "press": tapping on in Home app fires press command, tile resets to off within ~1 second
  • Bot with botMode: "press": tapping off (briefly visible during the reset window) is a no-op

🤖 Generated with Claude Code

Roshun Sasha and others added 2 commits June 29, 2026 09:19
Adds an optional `botMode: "press"` per-device config field for Bot
accessories. When set, tapping the switch in the Home app sends a single
`press` command instead of `turnOn`/`turnOff`, and the On characteristic
auto-resets to false after 1 second so the tile behaves like a momentary
button rather than a persistent toggle.

Default behavior (botMode omitted or "switch") is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@donavanbecker

Copy link
Copy Markdown
Contributor

@roshun, please resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants