Skip to content

Add a buzzer mute switch to Home Assistant discovery - #400

Open
jamesmulcahy wants to merge 1 commit into
NSPManager:develfrom
jamesmulcahy:feat/buzzer-mute
Open

jamesmulcahy wants to merge 1 commit into
NSPManager:develfrom
jamesmulcahy:feat/buzzer-mute

Conversation

@jamesmulcahy

Copy link
Copy Markdown
Contributor

Follow-up to #394: the "quiet mode" toggle from the review, controllable over MQTT from Home Assistant or OpenHAB.

Changes

  • HA discovery: each Sonoff panel gets a "Mute sounds" switch (homeassistant/switch/nspanelmanager/<mac>_buzzer_mute/config), using nspanel/<mac>/buzzer_mute_cmd and nspanel/<mac>/buzzer_mute_state with 1/0 payloads like the relay and screen switches. Custom panels don't get the switch, since only the Sonoff firmware drives a buzzer.
  • NSPanel: the manager subscribes to the command topic. When the mute changes it publishes the state and resends the config. While muted, send_config() leaves out every sounds entry; unmuting sends the configured sounds again.

Behaviour

  • Muting only silences the per-event sounds from Send per-event buzzer sounds to panels in NSPanelConfig #394 (touch, scene activated, scene saved). Sounds sent directly with buzzer_raw_command still play.
  • No protocol or firmware change: an event without a sound entry is already silent, so this works with the firmware as it is.
  • The switch is registered with retain: true, so the broker keeps the last command and the mute survives manager restarts. Panel reboots are covered because the config is resent when the panel registers. The retained command is only cleared when the panel is removed.
  • Each mute/unmute resends the full config. This resets anything Home Assistant changed only on the panel (screen brightness, screensaver brightness, screensaver mode) to the manager's stored values, as any config reload already does. A night automation should mute before dimming.

Testing

  • Full MQTTManager build in Docker plus --test: all 147 tests pass, including seven new ones in tests/nspanel_test.cpp (mute sends no sounds and unmute restores them, mute survives a config reload, a repeated command doesn't resend the config, an unknown payload is ignored, Sonoff panels register the retained switch, custom panels don't)
  • Not tested end to end against a live Home Assistant. The discovery message follows the existing switches.

🤖 Generated with Claude Code

Each Sonoff panel gets a "Mute sounds" switch. While it is on, the
manager sends the panel's config without any buzzer sounds, which
silences every event; turning it off sends the configured sounds again.
No protocol or firmware change is needed.

The switch is registered with retain, so the broker keeps the last
command and the mute survives manager restarts. The retained command is
only cleared when the panel is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant