Skip to content

Comments

Add support for actions and events#56

Merged
seime merged 5 commits intoseime:masterfrom
ccutrer:actions
Oct 7, 2025
Merged

Add support for actions and events#56
seime merged 5 commits intoseime:masterfrom
ccutrer:actions

Conversation

@ccutrer
Copy link
Contributor

@ccutrer ccutrer commented Oct 3, 2025

They get sent through the openHAB event bus, and can be used in rules via custom triggers. See updates in the readme and a screenshot for more details.

They get sent through the openHAB event bus, and can be used in
rules via custom triggers.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
@ccutrer
Copy link
Contributor Author

ccutrer commented Oct 3, 2025

I'm thinking we should implement several actions:

  • openhab.command - sends a command to an item
  • openhab.update - updates an item to a given state
  • openhab.script - executes a script by ID (though maybe just use script.<script_id>, since that's how Home Assistant triggers the similar concept)

As well as emulate some actions from Home Assistant:

  • homeassistant.turn_on
  • homeassistant.turn_off
  • homeassistant.toggle
  • homeassistant.update_entity (REFRESH)
  • look through other built in Home Assistant actions for other domains (my Home Assistant instance isn't currently running, and the live demo doesn't have the Developer Tools section, so I can't look right now)

It would be really cool if we could bridge directly into openHAB actions, including Thing actions. Then if we also implement Thing actions to represent actions published by ESPHome devices, a device could even (semi-)directly call actions on other devices.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for actions and events from ESPHome devices, allowing them to send action requests, events, and tag scan notifications through the openHAB event bus for use in rules and automation.

  • Adds event handling for ESPHome actions, events, and tag scanning via new event types
  • Implements custom trigger handlers for UI-based automation rules
  • Adds configuration option to enable/disable action and event processing

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/main/java/no/seime/openhab/binding/esphome/events/*.java Event classes and factory for ESPHome action, event, and tag scanned events
src/main/java/no/seime/openhab/binding/esphome/internal/module/handler/*.java Trigger handlers and factory for automation module integration
src/main/java/no/seime/openhab/binding/esphome/internal/handler/ESPHomeHandler.java Main handler updates to process incoming actions/events and publish to event bus
src/main/resources/OH-INF/automation/moduletypes/*.json Automation trigger type definitions for UI integration
src/main/resources/OH-INF/thing/thing-esphome.xml Thing configuration for allowActions parameter
README.md Documentation for actions and events functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@seime
Copy link
Owner

seime commented Oct 4, 2025

Thanks @ccutrer, could you also create an integration test like the ones found here : src/test/java/no/seime/openhab/binding/esphome/devicetest ? In addition to further testing it also serves as an example for users.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
per discussion in openhab-core

Signed-off-by: Cody Cutrer <cody@cutrer.us>
Signed-off-by: Cody Cutrer <cody@cutrer.us>
Signed-off-by: Cody Cutrer <cody@cutrer.us>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/main/java/no/seime/openhab/binding/esphome/internal/handler/ESPHomeHandler.java:1

  • The comparison is checking if the event source equals the deviceId directly, but the event source is formatted as 'no.seime.openhab.binding.esphome$deviceId'. This comparison should use the formatted source or extract the device ID from the source.
/**

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@seime
Copy link
Owner

seime commented Oct 6, 2025

Also, the latest comment from copilot doesn't make sense to me, but you might understand where in the codebase it actually refers to?

@ccutrer
Copy link
Contributor Author

ccutrer commented Oct 6, 2025

Also, the latest comment from copilot doesn't make sense to me, but you might understand where in the codebase it actually refers to?

The one about comparing the event source to the device id directly? Yeah, I have no idea what it's talking about there. There is no comparison against event source in ESPHomeHandler.java. I didn't even see it at first because it's tagged as "low confidence".

@seime seime merged commit 7cde273 into seime:master Oct 7, 2025
2 checks passed
@seime
Copy link
Owner

seime commented Oct 7, 2025

Thanks for contributing @ccutrer !

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