Example #1
0
        public async Task TestFakeAppCallNoteWhenBatteryLevelBelowValue()
        {
            // Add the app to test
            await using var fakeApp = new FakeApp();
            await AddAppInstance(fakeApp).ConfigureAwait(false);

            // Init NetDaemon core runtime
            await InitializeFakeDaemon().ConfigureAwait(false);

            // Fake a changed event from en entity
            AddChangeEvent(new()
            {
                EntityId   = "sensor.temperature",
                State      = "10.0",
                Attributes = new Dictionary <string, object>()
                {
                    ["battery_level"] = 18.2
                }
            }
                           , new()
            {
                EntityId   = "sensor.temperature",
                State      = "10.0",
                Attributes = new Dictionary <string, object>()
                {
                    ["battery_level"] = 12.0
                }
            });

            // Run the NetDemon Core to process the messages
            await RunFakeDaemonUntilTimeout().ConfigureAwait(false);

            // Verify that netdaemon called light.turn_on
            VerifyCallService("notify", "notify", new { title = "Hello from Home Assistant" });
        }
Example #2
0
        public async Task TestFakeAppCallNoteWhenBatteryLevelBelowValue()
        {
            // Add the app to test
            await using var fakeApp = new FakeApp();
            await AddAppInstance(fakeApp).ConfigureAwait(false);

            // Init NetDaemon core runtime
            await InitializeFakeDaemon().ConfigureAwait(false);

            // Fake a changed event from en entity
            AddChangeEvent(new()
            {
                EntityId   = "sensor.temperature",
                State      = 10.0,
                Attributes = new()
                {
                    ["battery_level"] = 18.2
                }
Example #3
0
        public async Task TestFakeAppTurnOnCorrectLight()
        {
            // Add the app to test
            await using var fakeApp = new FakeApp();
            await AddAppInstance(fakeApp).ConfigureAwait(false);

            // Init NetDaemon core runtime
            await InitializeFakeDaemon().ConfigureAwait(false);

            // Fake a changed event from en entity
            AddChangedEvent("binary_sensor.kitchen", "off", "on");

            // Run the NetDemon Core to process the messages
            await RunFakeDaemonUntilTimeout().ConfigureAwait(false);

            // Verify that netdaemon called light.turn_on
            VerifyCallService("light", "turn_on", "light.kitchen");
        }