feat(netdaemon): make example of a script with params
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-10-05 14:43:43 -04:00
parent 559d9e0fbd
commit 919c3cbb66
9 changed files with 26 additions and 42 deletions

View file

@ -0,0 +1,22 @@
namespace AppModel;
record ServiceData(string? action, int value);
/// <summary>
/// Showcases how to instance apps with yaml and use automatic configuration population
/// </summary>
[NetDaemonApp]
public class TestScript
{
public TestScript(IHaContext ha)
{
ha.RegisterServiceCallBack<ServiceData>(
"callback_demo",
e => ha.CallService(
"notify",
"persistent_notification",
data: new {message = $"value: {e?.value}", title = $"{e?.action}"}
)
);
}
}

View file

@ -1,19 +0,0 @@
namespace AppModel;
/// <summary>
/// Showcases how to instance apps with yaml and use automatic configuration population
/// </summary>
[NetDaemonApp]
public class HelloYamlApp
{
public HelloYamlApp(IHaContext ha, IAppConfig<HelloConfig> config)
{
ha.CallService("notify", "persistent_notification",
data: new {message = config.Value.HelloMessage, title = "Hello yaml app!"});
}
}
public class HelloConfig
{
public string? HelloMessage { get; set; }
}

View file

@ -1,2 +0,0 @@
AppModel.HelloConfig:
HelloMessage: Hello from yaml

View file

@ -4,3 +4,4 @@ global using System.Reactive.Linq;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using NetDaemon.AppModel; global using NetDaemon.AppModel;
global using NetDaemon.HassModel; global using NetDaemon.HassModel;
global using NetDaemon.HassModel.Integration;

View file

@ -1,16 +0,0 @@
// Use unique namespaces for your apps if you going to share with others to avoid
// conflicting names
namespace HassModel;
/// <summary>
/// Hello world showcase using the new HassModel API
/// </summary>
[NetDaemonApp]
public class HelloWorldApp
{
public HelloWorldApp(IHaContext ha)
{
ha.CallService("notify", "persistent_notification", data: new {message = "Notify me", title = "Hello world!"});
}
}

View file

@ -62,6 +62,7 @@ in {
done done
${compiled.passthru.fetch-deps} . ${compiled.passthru.fetch-deps} .
alejandra .
''; '';
}) })
]; ];

View file

@ -196,11 +196,6 @@
version = "24.37.1"; version = "24.37.1";
hash = "sha256-eIOk6/LImCTjTC4cwWBpATqxiQUQxbsRXAcR6Mz7LKs="; hash = "sha256-eIOk6/LImCTjTC4cwWBpATqxiQUQxbsRXAcR6Mz7LKs=";
}) })
(fetchNuGet {
pname = "NetDaemon.HassModel.CodeGen";
version = "24.37.0";
hash = "sha256-+YSo9/FkkDLfymWrzf4OjMwE31qjAbbFjmF7L5Aj2Bg=";
})
(fetchNuGet { (fetchNuGet {
pname = "NetDaemon.HassModel.Integration"; pname = "NetDaemon.HassModel.Integration";
version = "24.37.1"; version = "24.37.1";

View file

@ -29,6 +29,7 @@
<PackageReference Include="NetDaemon.AppModel" Version="24.37.1" /> <PackageReference Include="NetDaemon.AppModel" Version="24.37.1" />
<PackageReference Include="NetDaemon.Runtime" Version="24.37.1" /> <PackageReference Include="NetDaemon.Runtime" Version="24.37.1" />
<PackageReference Include="NetDaemon.HassModel" Version="24.37.1" /> <PackageReference Include="NetDaemon.HassModel" Version="24.37.1" />
<PackageReference Include="NetDaemon.HassModel.Integration" Version="24.37.1" />
<PackageReference Include="NetDaemon.Client" Version="24.37.1" /> <PackageReference Include="NetDaemon.Client" Version="24.37.1" />
<PackageReference Include="NetDaemon.Extensions.Scheduling" Version="24.37.1" /> <PackageReference Include="NetDaemon.Extensions.Scheduling" Version="24.37.1" />
<PackageReference Include="NetDaemon.Extensions.Logging" Version="24.37.1" /> <PackageReference Include="NetDaemon.Extensions.Logging" Version="24.37.1" />