public async Task <int> OnExecuteAsync(IConsole console)
        {
            var address = IPAddress.Parse(TargetDevice);

            if (ShowJson)
            {
                var bulb = new LightBulb(address);
                await bulb.FetchAsync().ConfigureAwait(false);

                console.WriteLine(_jsonService.Serialize(bulb));
            }
            else
            {
                var desiredState = new RequestedBulbState();

                SwitchState desiredSwitchState = SwitchState.Off;

                bool shouldToggleState = false;

                if (string.Equals(DesiredState, "toggle", StringComparison.InvariantCultureIgnoreCase))
                {
                    shouldToggleState = true;
                }
                else if (Enum.TryParse(DesiredState, true, out desiredSwitchState))
                {
                    desiredState.PowerState = desiredSwitchState;
                }
                else
                {
                    throw new Exception("Invalid value for parameter \"state\".");
                }
                if (Brightness != null)
                {
                    desiredState.Brightness = Brightness;
                }

                var bulb = new LightBulb(address);
                if (shouldToggleState)
                {
                    await bulb.FetchAsync().ConfigureAwait(false);

                    desiredState.PowerState = bulb.State.PowerState == SwitchState.Off ? SwitchState.On : SwitchState.Off;
                }
                await bulb.TransitionStateAsync(desiredState).ConfigureAwait(false);
            }
            return(0);
        }