feat(bot): add botMode: "press" option for momentary-button behavior#1395
Open
roshun wants to merge 2 commits into
Open
feat(bot): add botMode: "press" option for momentary-button behavior#1395roshun wants to merge 2 commits into
roshun wants to merge 2 commits into
Conversation
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>
Contributor
|
@roshun, please resolve conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
botMode: "press"per-device config field for Bot accessoriespresscommand (notturnOn/turnOff) and theOncharacteristic auto-resets tofalseafter 1 secondbotModeomitted or"switch") is unchangedMotivation
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.createHAPAccessoryis overridden; whenbotMode !== "press"it falls through tosuper.createHAPAccessoryso existing behavior is fully preservedSwitchBotHAPPlatform.registerHAPAccessoriesstores the HAPOncharacteristic on theBotDeviceinstance afteronSetregistration, so the 1-second reset timer can callcharacteristic.updateValue(false)without needing a platform referencetsc --noEmitTest plan
botModeset: on/off toggle works as beforebotMode: "press": tapping on in Home app firespresscommand, tile resets to off within ~1 secondbotMode: "press": tapping off (briefly visible during the reset window) is a no-op🤖 Generated with Claude Code