public async Task TransitionStateAsync(SwitchState powerState, int transitionPeriod = 0) { var state = new RequestedBulbState() { PowerState = powerState }; await TransitionStateAsync(state, transitionPeriod) .ConfigureAwait(false); }
public async Task TransitionStateAsync(RequestedBulbState state, int transitionPeriod = 0) { if (IsDimmable != null && !(bool)IsDimmable) { throw new NotSupportedException("Light bulb is not dimmable.s"); } bool?powerState = null; if (state.PowerState != null) { powerState = state.PowerState == SwitchState.On; } string result = await SendCommand( Commands .TransitionLightState(powerState, transitionPeriod, state.Hue, state.Saturation, state.ColorTemp, state.Brightness)) .ConfigureAwait(false); JObject obj = ParseSmartBulbTransitionLightStateResponse(result); int code = GetErrorCode(obj); UpdateBulbState(obj); }