Get list of (all) entities that match pattern in AppDaemon

I there a way to get a list of all entities that match a string or pattern? Or just all entities that can be filtered afterwards?

I am writing apps to automate upgrades (or at least allow an “update all” option in actionable notifications), and I don’t want to hardcode all ESPHome devices, since this list changes a bit more than others.

You can use get_state() or get_state("domain") to retrieve a dictionary of all entities (or all entities with a specific domain like “sensor”), and their attributes. Once you have that data stored in a variable you can iterate and filter that way. You wont want to perform this action frequently so only do it under initialize() and/or on a schedule.

1 Like

Awesome, that’s perfect. Thanks!