Skip to content

Fix MQTT service availability check in Home Assistant addon#306

Merged
tomquist merged 2 commits into
developfrom
claude/fix-mqtt-insights-config-hyPAi
Apr 6, 2026
Merged

Fix MQTT service availability check in Home Assistant addon#306
tomquist merged 2 commits into
developfrom
claude/fix-mqtt-insights-config-hyPAi

Conversation

@tomquist
Copy link
Copy Markdown
Owner

@tomquist tomquist commented Apr 6, 2026

Summary

Updated the MQTT service availability check to use the correct Home Assistant bashio function.

Changes

  • Changed bashio::services "mqtt" to bashio::services.available "mqtt" to properly check if the MQTT service is available before attempting to access its configuration

Details

The original code was using an incorrect bashio function syntax. The bashio::services.available function is the proper way to check if a service is available in Home Assistant before attempting to retrieve its configuration details. This prevents potential errors when the MQTT service is not installed or available on the system.

https://claude.ai/code/session_019CfQvHfhZLrbnThz63fDW9

Summary by CodeRabbit

  • Bug Fixes
    • Improved MQTT service availability detection to ensure the MQTT configuration section and broker settings are only displayed when the service is actually available.

claude added 2 commits April 6, 2026 21:01
`bashio::services mqtt` performs a supervisor API call that errors with
"Service not enabled" and still produced output that let the if-branch
run, so the generated config contained an empty `[MQTT_INSIGHTS]`
section when no Mosquitto add-on was available. Use
`bashio::services.available` for a proper availability check.

https://claude.ai/code/session_019CfQvHfhZLrbnThz63fDW9
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a02e380b-0795-4a74-a182-2f679e1b9707

📥 Commits

Reviewing files that changed from the base of the PR and between 4bc34a0 and 5b02581.

📒 Files selected for processing (1)
  • ha_addon/run.sh

Walkthrough

A single-line modification in the shell script replaces the MQTT service availability check method from bashio::services "mqtt" to bashio::services.available "mqtt", affecting how the MQTT configuration block is conditionally rendered.

Changes

Cohort / File(s) Summary
MQTT Service Check
ha_addon/run.sh
Replaced bashio::services "mqtt" with bashio::services.available "mqtt" to correctly verify MQTT service availability before rendering the MQTT configuration block.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the MQTT service availability check in the Home Assistant addon by using the correct bashio function.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-mqtt-insights-config-hyPAi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomquist tomquist merged commit 5432f4a into develop Apr 6, 2026
13 checks passed
@tomquist tomquist deleted the claude/fix-mqtt-insights-config-hyPAi branch April 6, 2026 21:17
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