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.
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 atarget
instead. This PR checks the service definition to determine the correct place to put the user-selectedentity_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.