Expose user-defined ESPHome services as first-class API functions - #2
Merged
Conversation
Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Expose user defined services as function
Expose user-defined ESPHome services as first-class API functions
Feb 21, 2026
Co-authored-by: DutchmanNL <7318445+DutchmanNL@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR exposes ESPHome “user-defined services” through the public library API (service discovery + execution) so consumers no longer need to use pb internals.
Changes:
- Extend
listEntitiesService()to includeListEntitiesServicesResponseentries (component"Services"). - Add
executeServiceService({ key, args })to sendExecuteServiceRequestwith typed arguments. - Export
ServiceArgType, update TypeScript declarations, and document discovery/execution usage in the README.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| lib/connection.js | Adds services discovery to the entity listing + implements service execution request building. |
| index.js | Exports a friendly ServiceArgType mapping derived from the protobuf enum. |
| index.d.ts | Adds typings for service discovery/execution data and connection event overloads. |
| README.md | Documents how to discover and call user-defined services and the related connection event. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
ListEntitiesServicesResponse(msg twocolors#41) andExecuteServiceRequest(msg twocolors#42) existed in the protobuf layer but were not surfaced through the library, forcing consumers to reach intopbinternals to use user-defined services.Changes
lib/connection.jslistEntitiesService()now collectsListEntitiesServicesResponseentries (exposed ascomponent: 'Services')executeServiceService({ key, args })— builds and sendsExecuteServiceRequest, supporting all 8 arg types (bool,int,float,string, and their array variants)index.js— exportsServiceArgTypewith friendly keys (Bool,Int,Float,String,BoolArray,IntArray,FloatArray,StringArray) mapped from the protobuf enumindex.d.ts— addsServiceArgType,ListEntitiesServicesArgument,ListEntitiesServicesResponse,ExecuteServiceArgument,ExecuteServiceCommandData; extendsComponents,Entities,Connection, and addson/offoverloads formessage.ListEntitiesServicesResponseREADME.md— new synopsis example +### User-defined Servicessection documentingServiceArgTypevalues, service discovery, execution, and the raw connection eventUsage
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.