Get entities by area

When using the get entities node is there any way you can filter the entities retuned based upon the area that they are assigned to in home Assistant?

In this case I’m trying to setup automations for when I play media so that it will automatically adjust lights and such - but would be nice if it could dynamically determine the entities to adjust based upon their area and the area of the media player being used (also saves me from having to adjust the automation as I add smart controls to additional secondary lights)

You can target areas from a call-service node.

https://www.home-assistant.io/docs/scripts/service-calls/#targeting-areas-and-devices

That won’t allow me to do what I want. While sure I could manage to turn all the lights off with that I couldn’t do things like save the previous state and return it to that state when I’m finished watching.

You can use the top portion of this flow to get all the devices and entities in an area.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/cookbook/get-state_changed-events-based-on-area.html

Looks like they added a new endpoint since the last time i looked.

image

[{"id":"5594edbf.473a34","type":"ha-api","z":"56b1c979.b2c618","name":"","server":"","debugenabled":false,"protocol":"websocket","method":"get","path":"","data":"{\t   \"type\":\"search/related\",\t   \"item_type\":\"area\",\t   \"item_id\":\"kitchen\"\t}","dataType":"jsonata","location":"payload","locationType":"msg","responseType":"json","x":322,"y":2064,"wires":[["5354f212.4fb41c"]]},{"id":"e11b6e5.46d4b9","type":"inject","z":"56b1c979.b2c618","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":156,"y":2064,"wires":[["5594edbf.473a34"]]},{"id":"5354f212.4fb41c","type":"debug","z":"56b1c979.b2c618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":518,"y":2064,"wires":[]}]

Thanks, this looks very useful. Do you know if there is a good reference of the requests you’d be able to give to that API, just could be useful for the future. But this at least gives me a way forward with what I’m currently looking at.

Don’t know if there is a good complete reference (https://developers.home-assistant.io/docs/api/websocket covers the basics) - but was able to determine how to find them in the code - so easy to figure it out for at least ones in the core components.

Thanks again for the hint @Kermit

Just in case I need it myself and search the forum again. :stuck_out_tongue:

This search brings up websocket API endpoints: