how can I receive the entity_ids related to a specific device_id within python_script?
I have found a description how this is done within custom components (How I can get DeviceEntry by entity_id in python?) but this requires some import which is not possible within python_script.
I additionally found how this can be done within templates (Templating - Home Assistant), but still no option how the same as template: “device_entities(device_id)” is achieved within python_script.
I should clarify that you may not have access to this information, but the point of my response was to show you that you can get any example from the HA code as the calls are identical in python_scripts.
but I do not think this is a XY problem
My intention is to have a script which does activity guessing for a person within my home.
For this I have used the custom variable integration and created a variable for every person.
This variable holds different device_id’s or entity_id’s as attributes like e.g:
Furthermore I have a variable which holds different “home” device_id’s / entity_id’s (like washing_machine, tv, ceramic_hobin, dishwasher, fridge etc.) the same way as attributes dict.
With help of combining these states I should be at a good position to guess the current activity of a person within my home. But as you see some of them are entities, some of them are devices (which is btw. intended as for some of them I have more information so I am able to do a more reliable guessing, and for some of them I only have that single state entity where I mostly can only do a best guess).
So what I need to do at some point within the script is extend the device_id’s to entity lists to be able to get the corresponding states.
Just if somebody else comes around this and is interested how I handled this.
I am using a custom integration now which allows imports…not awesome (as I would have preferred to use the built in python_scripts component with the device_entities command - but as said this one is not defined) so at the moment the best way to go as I see it: AlexxIT/PythonScriptsPro: Advanced version of python scripts for Home Assistant without limits (github.com)