Skip to content

feat: add ha_fire_event tool for firing events on the HA event bus (#996)#1228

Closed
SealKan wants to merge 3 commits into
homeassistant-ai:masterfrom
SealKan:feat/996-fire-event
Closed

feat: add ha_fire_event tool for firing events on the HA event bus (#996)#1228
SealKan wants to merge 3 commits into
homeassistant-ai:masterfrom
SealKan:feat/996-fire-event

Conversation

@SealKan
Copy link
Copy Markdown
Contributor

@SealKan SealKan commented May 11, 2026

Closes #996

Adds ha_fire_event(event_type, data=None) — fires arbitrary HA events via POST /api/events/{event_type}.

ha_call_service covers service calls; firing a raw event is a distinct mechanism used by event-triggered automations and custom integrations. The underlying HomeAssistantClient.fire_event() already exists in rest_client.py.

Verb fire: Not in the approved-verb list yet. Happy to rename (trigger, send, emit) or add fire to AGENTS.md — your call.

3 files changed: tool implementation + 7 unit tests + E2E test.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new tool, ha_fire_event, which enables the ability to trigger custom events within Home Assistant. This functionality is intended for use with event-triggered automations, custom integrations, or external systems like Node-RED, complementing the existing service call capabilities.

Highlights

  • New Tool Implementation: Added the ha_fire_event tool to allow firing arbitrary events on the Home Assistant event bus.
  • Data Validation: Implemented JSON parsing for event data, ensuring that only dictionary objects are accepted and providing descriptive errors for invalid inputs.
  • Comprehensive Testing: Added both unit tests and E2E tests to verify event firing functionality, including handling of JSON strings, dictionary data, and error scenarios.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@SealKan
Copy link
Copy Markdown
Contributor Author

SealKan commented May 11, 2026

Closing — will resubmit once existing PRs (#1207, #1225) are reviewed and merged.

@SealKan SealKan closed this May 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ha_fire_event tool to the Home Assistant MCP service, allowing AI agents to fire custom events on the Home Assistant event bus. The implementation includes comprehensive unit and end-to-end tests covering various data formats and error scenarios. Feedback is provided regarding compliance with the repository's style guide, specifically concerning the approved verb list for tool naming and the required structure for multi-line docstrings, including the 'Caveats' section.

Comment thread src/ha_mcp/tools/tools_service.py
Comment thread src/ha_mcp/tools/tools_service.py
@SealKan SealKan reopened this May 11, 2026
@SealKan SealKan force-pushed the feat/996-fire-event branch from 7233009 to af05f1c Compare May 11, 2026 13:35
@SealKan SealKan force-pushed the feat/996-fire-event branch from af05f1c to a7e6298 Compare May 11, 2026 13:38
…cstring (homeassistant-ai#996)

- Add `fire` verb to AGENTS.md approved-verb list as Gemini suggested
- Add Caveats section to ha_fire_event docstring: events are fire-and-forget
@SealKan SealKan marked this pull request as ready for review May 11, 2026 13:40
@SealKan SealKan requested review from a team and sergeykad May 11, 2026 13:40
- ha_fire_event fires events with side effects (triggers automations,
  subscribers) so destructiveHint=True is correct; False was bypassing
  the annotation compliance test
- Remove unused safe_call_tool import from test_ha_fire_event.py (ruff F401)
@SealKan
Copy link
Copy Markdown
Contributor Author

SealKan commented May 11, 2026

Closing to refocus resources. Will revisit when bandwidth allows.

@SealKan SealKan closed this May 11, 2026
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.

[FEATURE] Expose ha_fire_event tool (POST /api/events/{event_type})

1 participant