Skip to content

Commit 6ffaaee

Browse files
committed
add function states that returns all entities
1 parent 006cdc3 commit 6ffaaee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

custom_components/pyscript/handler.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, hass):
3030
"task.unique": self.task_unique,
3131
"service.call": self.service_call,
3232
"service.has_service": self.service_has_service,
33+
"states": self.states,
3334
}
3435

3536
#
@@ -53,6 +54,13 @@ def __init__(self, hass):
5354
#
5455
self.loggers = {}
5556

57+
async def states(self, domain=None):
58+
return [
59+
state
60+
for state in self.hass.states.keys()
61+
if state.split(".", 1)[0] == domain
62+
]
63+
5664
async def async_sleep(self, duration):
5765
"""Implement task.sleep()."""
5866
await asyncio.sleep(float(duration))

0 commit comments

Comments
 (0)