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(", ") }, });
/// <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(", ") } });
/// <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(", ") } });
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) }, });
/// <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() } });
/// <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() } });
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 } } });
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);
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);
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(", ") } });