Request to support for enitity_id in subscribe event command of websockets API

I am currently writing a ESP32 application with 2.4 inch display that can be used as control and monitor the home assistant entities. currently there are three ways to pull data from HA assistant.

  1. Use Official Home assistant REST API. (Usable but very slow (around 1.5 sec per enitity) to pull entity state from HA https server)
  2. Use Official Home assistant websockets API. (Currently there is no way to subscribe to changes in state of couple of entities and data for all the entities is difficult to handle in ESP32 SOC).
  3. Create custom automation to send state changes over MQTT. (Very fast and reliable but requires configuration to setup).

I am currently exploring option 2 as It is quite fast to retrieve state changes from home assistant but Ignoring irrelevant changes takes time.

It would be very helpful the Websocket API can support subscribing to entity’s (or group of entities) state changes as well.

Is there an official feature request for subscribing to state_changes for only select entity_ids?

I also need this feature to cut down on the volume of events – I’m only interested in state changes of two entities.

1 Like

Indeed. I would really love this. I have 8 smart plugs, all of them sending state updates for 10 different entities every 10 seconds, so at 80 state changes every 10 seconds. In 1 minute it received 615 state changes and 706 kB of data. In a day that’s 885.600 state changes and 1016 MB :sweat_smile:

Right now only interested in changes of like 2-4 entities, which are only updated every once in a while.

Currently doing REST API requests every 15 seconds, which is also not efficient. There is currently no efficient way.

This was working for me

            subscribe_payload = {
                "id": 1,
                "type": "subscribe_entities",               
                "entity_ids": ["binary_sensor.my_device_occupancy"]
            }
1 Like

Aw, what a coincidence! Couldn’t find this topic 2-3 weeks ago.

It was also discovered by someone else.

Check further details here: