Entity and Entities selection
To select what entity you want to perform actions on use the
Entities() starting point.
The examples does not use
ConfigureAwait(false) but can be used for even more efficency in the async context switching.
Example 1: Selects one entity to perform action on
This selects the
light.light1 to perform the
TurnOn action on. A full fluent API command ends with
ExecuteAsync() that execute the command now.
Example 2: Selects multiple entities to perform action on Here we have several options to turn on both light1 and light2.
This one takes a
IEnumerable<string> as input to selects multiple lights
Example 3: Selects multiple entities to perform action on using lambda
You can also use lambda expressions to select entities like select all lights that start name with
light.kitchen_. Now it gets really interesting to use advanced selections with little code using LINQ.
or select on attributes
Turn on all lights in the kitchen area:
There are some entities that has native support in the API.
Media player has support for the most common service calls through the FluentAPI.
The same multiple selections with
IEnumerable<string> and lambdas are supported like the
Lambdas can be used on states and attributes too. Like stop all media players currently playing something:
Todo: document input_select