diff --git a/exampleapps/apps/test2.cs b/exampleapps/apps/test2.cs
index 1bfd29d2b..b77a5c64d 100644
--- a/exampleapps/apps/test2.cs
+++ b/exampleapps/apps/test2.cs
@@ -25,6 +25,10 @@ public override async Task InitializeAsync()
// SetState("sensor.testing", "on", new { attributeobject = new { aobject = "hello" } });
RunEvery(TimeSpan.FromSeconds(5), () => Log("Hello world!"));
+ // foreach(var entity in EntityIds)
+ // {
+ // Log(entity);
+ // }
// RunDaily("13:00:00", () => Log("Hello world!"));
// RunIn(TimeSpan.FromSeconds(5), () => Entity("light.tomas_rum").TurnOn());
// Entity("light.tomas_rum")
diff --git a/exampleapps/apps/test2.yaml b/exampleapps/apps/test2.yaml
index b4da7d6f2..6d75816de 100644
--- a/exampleapps/apps/test2.yaml
+++ b/exampleapps/apps/test2.yaml
@@ -1,5 +1,5 @@
my_app:
class: NStest.BatteryManager
# HelloWorldSecret: !secret test_secret
- dependencies:
- - global_app
+ # dependencies:
+ # - global_app
diff --git a/src/App/NetDaemon.App/Common/INetDaemon.cs b/src/App/NetDaemon.App/Common/INetDaemon.cs
index 7d72dc600..34e7550cb 100644
--- a/src/App/NetDaemon.App/Common/INetDaemon.cs
+++ b/src/App/NetDaemon.App/Common/INetDaemon.cs
@@ -411,6 +411,10 @@ public interface INetDaemonAppBase :
///
public AppRuntimeInfo RuntimeInfo { get; }
+ ///
+ /// Returns all entities (EntityId) that are currently registered
+ ///
+ public IEnumerable EntityIds { get; }
}
///
diff --git a/src/App/NetDaemon.App/Common/NetDaemonAppBase.cs b/src/App/NetDaemon.App/Common/NetDaemonAppBase.cs
index 929f200e5..12bd20dea 100644
--- a/src/App/NetDaemon.App/Common/NetDaemonAppBase.cs
+++ b/src/App/NetDaemon.App/Common/NetDaemonAppBase.cs
@@ -176,6 +176,10 @@ public async Task RestoreAppStateAsync()
///
public AppRuntimeInfo RuntimeInfo => _runtimeInfo;
+ ///
+ public IEnumerable EntityIds => _daemon?.State.Select(n => n.EntityId) ??
+ throw new NullReferenceException("Deamon not expected to be null");
+
///
public void SaveAppState()
{
diff --git a/tests/NetDaemon.Daemon.Tests/Reactive/RxAppTest.cs b/tests/NetDaemon.Daemon.Tests/Reactive/RxAppTest.cs
index b7a916caa..0adcc1957 100644
--- a/tests/NetDaemon.Daemon.Tests/Reactive/RxAppTest.cs
+++ b/tests/NetDaemon.Daemon.Tests/Reactive/RxAppTest.cs
@@ -254,6 +254,20 @@ public async Task StatesShouldReturnCorrectEntity()
Assert.Equal("binary_sensor.pir", entity?.EntityId);
}
+ [Fact]
+ public async Task EntityIdsShouldReturnCorrectItems()
+ {
+ // ARRANGE
+ var daemonTask = await GetConnectedNetDaemonTask();
+ // ACT
+ var entities = DefaultDaemonRxApp.EntityIds.ToList();
+
+ await daemonTask.ConfigureAwait(false);
+ // ASSERT
+ Assert.NotNull(entities);
+ Assert.Equal(8, entities.Count());
+ }
+
[Fact]
public async Task UsingEntitiesLambdaNewEventShouldCallFunction()
{