public static string ToStr(this DimmerMode mode) { return(mode switch { DimmerMode.None => "none", DimmerMode.GentleOnOff => "gentle_on_off", DimmerMode.InstantOnOff => "instant_on_off", DimmerMode.Preset => "customize_preset", _ => "", });
/// <summary> /// Configures change mode on long press of switch /// </summary> public async Task SetLongPressAction(DimmerMode mode, int index = 0) { if (mode == DimmerMode.Preset) { if (index < 0 || index > 3) { throw new ArgumentException("index should be between 0 and 3"); } await Execute("smartlife.iot.dimmer", "set_long_press_action", new JObject { new JProperty("mode", mode.ToStr()), new JProperty("index", index) }).ConfigureAwait(false); } else { await Execute("smartlife.iot.dimmer", "set_long_press_action", "mode", mode.ToStr()).ConfigureAwait(false); } _options.LongPressAction = mode; }