feat(netdaemon): make example of a script with params
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
559d9e0fbd
commit
919c3cbb66
9 changed files with 26 additions and 42 deletions
|
@ -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}"}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -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; }
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
AppModel.HelloConfig:
|
||||
HelloMessage: Hello from yaml
|
|
@ -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;
|
||||
|
|
|
@ -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!"});
|
||||
}
|
||||
}
|
|
@ -62,6 +62,7 @@ in {
|
|||
done
|
||||
|
||||
${compiled.passthru.fetch-deps} .
|
||||
alejandra .
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<PackageReference Include="NetDaemon.AppModel" Version="24.37.1" />
|
||||
<PackageReference Include="NetDaemon.Runtime" 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.Extensions.Scheduling" Version="24.37.1" />
|
||||
<PackageReference Include="NetDaemon.Extensions.Logging" Version="24.37.1" />
|
||||
|
|
Loading…
Reference in a new issue