protected async Task Handle(ModeSetCommand message) { //Surround support only in main zone if (_zone != 1) { return; } var surroundMode = message.AsString(MessageProperties.SurroundMode); var mode = DenonSurroundModes.MapApiCommand(surroundMode); if (mode?.Length == 0) { throw new ArgumentException($"Surroundmode {mode} was not found on available surround modes"); } var control = new DenonControlQuery { Command = mode, Api = "formiPhoneAppDirect", ReturnNode = "", Zone = "", Address = _hostName }; await MessageBroker.QueryService <DenonControlQuery, string>(control).ConfigureAwait(false); _surround = await UpdateState(SurroundSoundState.StateName, _surround, surroundMode).ConfigureAwait(false); }
protected async Task SetInput(InputSetCommand message) { if (_fullState == null) { throw new ArgumentException("Cannot change input source on Denon device because device info was not downloaded from device"); } var inputName = message.AsString(MessageProperties.InputSource); var input = _fullState.TranslateInputName(inputName, _zone.ToString()); if (input?.Length == 0) { throw new ArgumentException($"Input {inputName} was not found on available device input sources"); } var control = new DenonControlQuery { Command = input, Api = "formiPhoneAppDirect", ReturnNode = "", Zone = "", Address = _hostName }; await MessageBroker.QueryService <DenonControlQuery, string>(control).ConfigureAwait(false); _input = await UpdateState(InputSourceState.StateName, _input, inputName).ConfigureAwait(false); }
protected async Task Handle(UnmuteCommand message) { var control = new DenonControlQuery { Command = "MuteOff", Api = "formiPhoneAppMute", ReturnNode = "Mute", Address = _hostName, Zone = _zone.ToString() }; if (await MessageBroker.QueryServiceWithVerify <DenonControlQuery, string, object>(control, "off").ConfigureAwait(false)) { _mute = await UpdateState(MuteState.StateName, _mute, false).ConfigureAwait(false); } }
protected async Task Handle(TurnOffCommand message) { var control = new DenonControlQuery { Command = "PowerStandby", Api = "formiPhoneAppPower", ReturnNode = "Power", Address = _hostName, Zone = _zone.ToString() }; if (await MessageBroker.QueryServiceWithVerify <DenonControlQuery, string, object>(control, "OFF").ConfigureAwait(false)) { _powerState = await UpdateState(PowerState.StateName, _powerState, false).ConfigureAwait(false); } }
protected async Task Handle(TurnOnCommand message) { var control = new DenonControlQuery { Command = "PowerOn", Api = "formiPhoneAppPower", ReturnNode = "Power", Address = _hostName, Zone = _zone.ToString() }; if (await MessageBroker.QueryServiceWithVerify <DenonControlQuery, string, object>(control, "ON").ConfigureAwait(false)) { _powerState = await UpdateState(PowerState.StateName, _powerState, true).ConfigureAwait(false); } Logger.LogInformation("Remote message received"); }
protected async Task Handle(VolumeSetCommand command) { var volume = command.AsDouble(MessageProperties.Value); var normalized = NormalizeVolume(volume); var control = new DenonControlQuery { Command = normalized, Api = "formiPhoneAppVolume", ReturnNode = "MasterVolume", Address = _hostName, Zone = _zone.ToString() }; await MessageBroker.QueryService <DenonControlQuery, string>(control).ConfigureAwait(false); _volume = await UpdateState(VolumeState.StateName, _volume, volume).ConfigureAwait(false); }
protected async Task Handle(VolumeDownCommand command) { if (_volume.HasValue) { var changeFactor = command.AsDouble(MessageProperties.ChangeFactor, DEFAULT_VOLUME_CHANGE_FACTOR); var volume = _volume - changeFactor; var normalized = NormalizeVolume(volume.Value); var control = new DenonControlQuery { Command = normalized, Api = "formiPhoneAppVolume", ReturnNode = "MasterVolume", Address = _hostName, Zone = _zone.ToString() }; // Results are unpredictable so we ignore them await MessageBroker.QueryService <DenonControlQuery, string>(control).ConfigureAwait(false); _volume = await UpdateState(VolumeState.StateName, _volume, volume).ConfigureAwait(false); } }