diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.cs b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.cs new file mode 100644 index 00000000..daf6bd7c --- /dev/null +++ b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.cs @@ -0,0 +1,22 @@ +namespace AppModel; + +record ServiceData(string? action, int value); + +/// +/// Showcases how to instance apps with yaml and use automatic configuration population +/// +[NetDaemonApp] +public class TestScript +{ + public TestScript(IHaContext ha) + { + ha.RegisterServiceCallBack( + "callback_demo", + e => ha.CallService( + "notify", + "persistent_notification", + data: new {message = $"value: {e?.value}", title = $"{e?.action}"} + ) + ); + } +} diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.yaml b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.yaml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/TestScript/TestScript.yaml @@ -0,0 +1 @@ + diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.cs b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.cs deleted file mode 100644 index 73185228..00000000 --- a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace AppModel; - -/// -/// Showcases how to instance apps with yaml and use automatic configuration population -/// -[NetDaemonApp] -public class HelloYamlApp -{ - public HelloYamlApp(IHaContext ha, IAppConfig config) - { - ha.CallService("notify", "persistent_notification", - data: new {message = config.Value.HelloMessage, title = "Hello yaml app!"}); - } -} - -public class HelloConfig -{ - public string? HelloMessage { get; set; } -} \ No newline at end of file diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.yaml b/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.yaml deleted file mode 100644 index d709335c..00000000 --- a/devices/homie/modules/home-assistant/netdaemon/apps/AppModel/YamlConfigApp/YamlConfigApp.yaml +++ /dev/null @@ -1,2 +0,0 @@ -AppModel.HelloConfig: - HelloMessage: Hello from yaml \ No newline at end of file diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/GlobalUsings.cs b/devices/homie/modules/home-assistant/netdaemon/apps/GlobalUsings.cs index b2d698e3..f0c6b67f 100644 --- a/devices/homie/modules/home-assistant/netdaemon/apps/GlobalUsings.cs +++ b/devices/homie/modules/home-assistant/netdaemon/apps/GlobalUsings.cs @@ -4,3 +4,4 @@ global using System.Reactive.Linq; global using Microsoft.Extensions.Logging; global using NetDaemon.AppModel; global using NetDaemon.HassModel; +global using NetDaemon.HassModel.Integration; diff --git a/devices/homie/modules/home-assistant/netdaemon/apps/HassModel/HelloWorld/HelloWorld.cs b/devices/homie/modules/home-assistant/netdaemon/apps/HassModel/HelloWorld/HelloWorld.cs deleted file mode 100644 index 2b57d13c..00000000 --- a/devices/homie/modules/home-assistant/netdaemon/apps/HassModel/HelloWorld/HelloWorld.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Use unique namespaces for your apps if you going to share with others to avoid -// conflicting names - -namespace HassModel; - -/// -/// Hello world showcase using the new HassModel API -/// -[NetDaemonApp] -public class HelloWorldApp -{ - public HelloWorldApp(IHaContext ha) - { - ha.CallService("notify", "persistent_notification", data: new {message = "Notify me", title = "Hello world!"}); - } -} \ No newline at end of file diff --git a/devices/homie/modules/home-assistant/netdaemon/default.nix b/devices/homie/modules/home-assistant/netdaemon/default.nix index a7fb97ed..61ca4359 100644 --- a/devices/homie/modules/home-assistant/netdaemon/default.nix +++ b/devices/homie/modules/home-assistant/netdaemon/default.nix @@ -62,6 +62,7 @@ in { done ${compiled.passthru.fetch-deps} . + alejandra . ''; }) ]; diff --git a/devices/homie/modules/home-assistant/netdaemon/deps.nix b/devices/homie/modules/home-assistant/netdaemon/deps.nix index 0aa55661..05f5107b 100644 --- a/devices/homie/modules/home-assistant/netdaemon/deps.nix +++ b/devices/homie/modules/home-assistant/netdaemon/deps.nix @@ -196,11 +196,6 @@ version = "24.37.1"; hash = "sha256-eIOk6/LImCTjTC4cwWBpATqxiQUQxbsRXAcR6Mz7LKs="; }) - (fetchNuGet { - pname = "NetDaemon.HassModel.CodeGen"; - version = "24.37.0"; - hash = "sha256-+YSo9/FkkDLfymWrzf4OjMwE31qjAbbFjmF7L5Aj2Bg="; - }) (fetchNuGet { pname = "NetDaemon.HassModel.Integration"; version = "24.37.1"; diff --git a/devices/homie/modules/home-assistant/netdaemon/netdaemon.csproj b/devices/homie/modules/home-assistant/netdaemon/netdaemon.csproj index a98da190..87eb8c94 100644 --- a/devices/homie/modules/home-assistant/netdaemon/netdaemon.csproj +++ b/devices/homie/modules/home-assistant/netdaemon/netdaemon.csproj @@ -29,6 +29,7 @@ +