Configuration
All configuration is done with the in yaml files. For clarity we recommend to have one yaml file for each app, named the same as the csharp file but you can configure as many apps and types in one to many yaml files if that is prefered.
Allways use nullable types!
#
Application instance configurationExample below instanciates an application with id light_manager_kitchen
and sets a configuration named the_light
to a string used by the LightManager
class.
lightmanager.yaml
Inside the app the the_light
setting is automatically provisioned to the TheLight
property if provided in the class. NetDaemon converts python style (used in Home Assistant) to c# style property names. You could use the name the_light
for the property too.
#
Instantiating Strongly Typed EntitiesMany of the basic entity types can be created from a string in the YAML. This avoids having to create them later and you have the simple methods like TurnOn/TurnOff ready to go.
humiditycontrol.yaml
Note - Currently this cannot be used with a lists or IEnumerable of entities. But this functionality should be included in a release soon.
#
Advanced configurations optionsYaml type | .NET type |
---|---|
Scalar a_string: hello world an_int: 10 a_bool: true | string? AString {get;set;} int? AnInt {get;set;} bool? ABool {get;set;} |
Sequences simple_list: - Hello - World | IEnumerable<string>? SimpleList {get;set;} sequences are always IEnumerable<type>, lists are not supported! |
Sequence complex | Se code example |
#
Example of complex data types supportThis example shows an example of how to use complex configuration options.
#
SecretsSecrets lets you store special variables that are global in the tree scope of the app. secrets.yaml
can be excluded in .gitignore
to makse sure sensitive data is not pushed to the git repo.
This is how to use secrets. Make any file called secrets.yaml
. The application will use the configuration in the first secret file it finds in the path.
secrets.yaml
app.yaml
depedning on what kind of secret you may have to quote the secret like this: