GET /api/areas REST endpoint

I would like to be able to query the area registry through the REST API.

I was looking for the same thing and found a Github PR for doing just that:

However it seems that PR was closed and it was recommended to use the websocket API instead. Maybe you can reopen the PR and argue for your use-case?

The dev team has indicated that they are not willing to reconsider that MR. If anyone else is interested in the feature, please vote here.

4 Likes

What principle exactly determines what features is available by the rest api and what not?
Iā€™m developing a client for a device that does not support websockets.
This artificial restriction makes it impossible to use the area-feature on that device, doesnā€™t it?

I donā€™t know that the devs are going to respond here. Please vote for this request if you want it.

I agreeā€¦
Yes, I could re-program everything to use websockets to get that data but why not expose that data via the REST API?
UPDATE apr-2022
Just tested websockets but the area_registry and device_registry donā€™t seem to be available anymore.
In that case this enhancement request should be back on the table?

Have you seen this?

    const [areas, devices, entities] = await Promise.all([
      info.hass.callWS({ type: "config/area_registry/list" }),
      info.hass.callWS({ type: "config/device_registry/list" }),
      info.hass.callWS({ type: "config/entity_registry/list" }),
    ]);
1 Like

Hello @anoblet
That was new to me. I did take a quick look, managed to create a dashboard based on the example but then realized this is outside my area of expertise :slight_smile:
(donā€™t have the time to dive into this vs. creating a python based dashboard in seconds if the right API endpoints are available).

Thanks anyway!

1 Like

Just ran into this issue myself.

@anoblet do you have any idea how to use this with the official home-assistant-js-websocket package?

It does not seem to include area_registry in the subscribeConfig function :frowning: and there still seems to be no way to get the list from the REST api which is quite frustrating.

1 Like

Iā€™m so confused as to WHY they refuse to do this? Itā€™s really wierdā€¦ seems like such a necessary and reasonable request. I want to sort my devices by room in my own UI, seems like alot of hassle having to manually write this for each device.

1 Like

You can do this via the REST /api/template endpoint:

curl -H 'Authorization: Bearer abc123' '<instance url>/api/template' -d '{"template": "{{ areas() }}"}'

Be sure to check out the REST API documentation, particularly on how to get the bearer token. You may find the templating documentation useful as well.

2 Likes