Example #1
0
        public async Task LightSwitchCommandAsync(string installedAppId,
                                                  string deviceId,
                                                  bool toggle)
        {
            _ = installedAppId ?? throw new ArgumentNullException(nameof(installedAppId));
            _ = deviceId ?? throw new ArgumentNullException(nameof(deviceId));

            try
            {
                var installedApp = await _installedAppManager.GetInstalledAppAsync(installedAppId).ConfigureAwait(false);

                var command = LightSwitch.GetDeviceCommand(toggle);
                await _smartThingsAPIHelper.DeviceCommandAsync(installedApp, deviceId, command);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception calling smartThingsAPIHelper.DeviceCommandAsync");
                throw;
            }
        }