Add ability to filter websocket subscriptions

I have started development of an Android app using the Websockets API.
When doing a subscription event I can filter only a specific type of events to recieve (which is great!) but it would be even greater if it were possible to send in another parameter to filter by entity id.

At the moment I have to do:

{
  "id": 3,
  "type": "subscribe_events",
  "event_type": "state_changed"
}

and then on my client handle every single message with an if-statement.
It would be so much nicer to be able to do:

{
  "id": 3,
  "type": "subscribe_events",
  "event_type": "state_changed",
  "entity_id": "light.bed_lamp"
}

I was also looking for this, and was looking how hard it was to create a pull reqest. But looking in the code i found it was already in there. is called “subscribe_trigger”, where “trigger” is the same thing you fill with a automation. a example is working:

{
            "id": 5,
            "type": "subscribe_trigger",
            "trigger":     {
                "platform": "state",
                "entity_id": "light.livingroom",
                "from": ["on", "off"]
            },
        }

just look at trigger and go to a yaml to json converter.

the PR: Add websocket trigger/condition commands by balloob · Pull Request #39109 · home-assistant/core · GitHub
There is also a “variables”. but i do not get how this is working. They test it with a hallo world event.
core/test_commands.py at cf1df5ff385ff6136280d62155a110d7711148c0 · home-assistant/core · GitHub

Edit: python variable was stil in the code

According to WebSocket - get state of single entity - #5 by nasa931 , this is now possible. I successfully subscribed to a single event with this method

Fun fact: your proposal is the same what ChatGPT was proposing to me :rofl: