コード例 #1
0
ファイル: Lights.cs プロジェクト: carldebilly/smarthome.net
 public static ApiCall Toggle(
     this HomeAssistantApi ha,
     params IDevice <ILight>[] lights)
 => ha.Execute("light", "toggle", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") },
 });
コード例 #2
0
ファイル: Fans.cs プロジェクト: carldebilly/smarthome.net
 /// <summary>
 /// Turns one or more fans on
 /// </summary>
 /// <param name="ha">The HA API</param>
 /// <param name="fans">Fans to turn on</param>
 /// <returns>An <see cref="ApiCall"/>.</returns>
 public static ApiCall TurnOn(
     this HomeAssistantApi ha,
     params IDevice <IFan>[] fans)
 => ha.Execute("fan", "turn_on", new Dictionary <string, object>
 {
     { "entity_id", fans.Select(l => l.Id).JoinBy(", ") }
 });
コード例 #3
0
 /// <summary>
 /// Toggles one or more boolean inputs
 /// </summary>
 /// <param name="ha">The HA API</param>
 /// <param name="inputs">The inputs to toggle</param>
 /// <returns>An <see cref="ApiCall"/>.</returns>
 public static ApiCall Toggle(
     this HomeAssistantApi ha,
     params IDevice <IInputBoolean>[] inputs)
 => ha.Execute("input_boolean", "toggle", new Dictionary <string, object>
 {
     { "entity_id", inputs.Select(l => l.Id).JoinBy(", ") }
 });
コード例 #4
0
ファイル: Lights.cs プロジェクト: carldebilly/smarthome.net
 public static ApiCall TurnOn(
     this HomeAssistantApi ha,
     double brightness,
     params IDevice <IDimmableLight>[] lights)
 => ha.Execute("light", "turn_on", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") },
     { "brightness", (int)(brightness * 255) },
 });
コード例 #5
0
ファイル: Fans.cs プロジェクト: carldebilly/smarthome.net
 /// <summary>
 /// Sets teh speed of one or more fans
 /// </summary>
 /// <param name="ha">The HA API</param>
 /// <param name="fans">Fans to configure</param>
 /// <returns>An <see cref="ApiCall"/>.</returns>
 public static ApiCall SetSpeed(
     this HomeAssistantApi ha,
     Fan.Speeds speed,
     params IDevice <IFan>[] fans)
 => ha.Execute("fan", "set_speed", new Dictionary <string, object>
 {
     { "entity_id", fans.Select(l => l.Id).JoinBy(", ") },
     { "speed", speed.ToString().ToLowerInvariant() }
 });
コード例 #6
0
 /// <summary>
 /// Sets the selected value one or more select inputs
 /// </summary>
 /// <param name="ha">The HA API</param>
 /// <param name="inputs">The select inputs to set</param>
 /// <returns>An <see cref="ApiCall"/>.</returns>
 public static ApiCall Select <T>(
     this HomeAssistantApi ha,
     T option,
     params IDevice <IInputSelect <T> >[] inputs)
 => ha.Execute("input_select", "select_option", new Dictionary <string, object>
 {
     { "entity_id", inputs.Select(l => l.Id).JoinBy(", ") },
     { "option", option.ToString() }
 });
コード例 #7
0
ファイル: Lights.cs プロジェクト: carldebilly/smarthome.net
 public static ApiCall TurnOn(
     this HomeAssistantApi ha,
     double brightness,
     Color color,
     params IDevice <IRGBLight>[] lights)
 => ha.Execute("light", "turn_on", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") },
     { "brightness", (int)(brightness * 255) },
     { "rgb_color", new int[] { color.R, color.G, color.B } }
 });
コード例 #8
0
ファイル: Lights.cs プロジェクト: carldebilly/smarthome.net
 public static Transition Toggle(
     this HomeAssistantApi ha,
     TimeSpan transition,
     params IDevice <ILight>[] lights)
 => new Transition(
     ha.Execute("light", "toggle", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") },
     { "transition", (int)transition.TotalSeconds }
 }),
     transition);
コード例 #9
0
ファイル: Lights.cs プロジェクト: carldebilly/smarthome.net
 public static Transition TurnOn(
     this HomeAssistantApi ha,
     double brightness,
     TimeSpan transition,
     params IDevice <IDimmableLight>[] lights)
 => new Transition(
     ha.Execute("light", "turn_on", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") },
     { "brightness", (int)(brightness * 255) },
     { "transition", (int)transition.TotalSeconds }
 }),
     transition);
コード例 #10
0
 public static ApiCall TurnOn(this HomeAssistantApi ha, params IDevice <ISwitch>[] lights)
 => ha.Execute("switch", "turn_on", new Dictionary <string, object>
 {
     { "entity_id", lights.Select(l => l.Id).JoinBy(", ") }
 });