home-assistant / developers.home-assistant

Developers website for Home Assistant.
https://developers.home-assistant.io
Other
311 stars 960 forks source link

Subscribe to trigger response appears to be wrong #2439

Open benwainwright opened 1 week ago

benwainwright commented 1 week ago

On the websocket API section that tells you how to subscribe to a trigger: https://developers.home-assistant.io/docs/api/websocket/#subscribe-to-trigger it says

For each trigger that matches, the server will send a message of type trigger. The id in the message will point at the original id of the subscribe_trigger command. Note that your variables will be different based on the used trigger.

Straight below that, there is a block of JSON that looks like a sample response... which has a type value of event. Either the response example is wrong, or the quoted statement needs rewording because it reads as contradictory. Happy to raise a PR if someone can confirm for me that I'm right.

MartinHjelmare commented 1 week ago

Here's the code for the websocket command:

https://github.com/home-assistant/core/blob/4ac35d40cd47071a52207ca1ecb69c695a2e196c/homeassistant/components/websocket_api/commands.py#L717-L765

The important part is here:

https://github.com/home-assistant/core/blob/4ac35d40cd47071a52207ca1ecb69c695a2e196c/homeassistant/components/websocket_api/commands.py#L741-L743

and here:

https://github.com/home-assistant/core/blob/4ac35d40cd47071a52207ca1ecb69c695a2e196c/homeassistant/components/websocket_api/messages.py#L107-L109

Looks like the code block is correct and the text needs updating.