bitfocus / companion-module-homeassistant-server

MIT License
12 stars 7 forks source link

fix: Send `entity_id` correctly within `CallService` action #38

Closed tjhorner closed 2 months ago

tjhorner commented 2 months ago

The current implementation will always send entity_id in the service payload, but this is not necessarily correct. Services may expect no entity IDs at all, or expect them as a target instead. This PR checks the service definition to determine the correct place to put the user-selected entity_id.

Also, FYI, the HA WebSocket library provides some nice convenience functions that provider stronger type checking, such as this one to call a service: https://github.com/home-assistant/home-assistant-js-websocket/blob/fdb007ff83306472a23c600023dc6ac853cadf33/lib/commands.ts#L23-L32

I didn't update the sendMessage calls to use them to limit the scope of this PR.

Julusian commented 2 months ago

Thanks. I've gone through and updated the usages of sendMessage and changed then to callService