Beispiel #1
0
 public IEnumerable <DeviceOperation> GetOperations(MqttAdapterEntry adapterEntry)
 {
     foreach (var service in _registeredOperationServices)
     {
         foreach (var operation in service.GetOperations(adapterEntry))
         {
             yield return(operation);
         }
     }
 }
        public IEnumerable <DeviceOperation> GetOperations(MqttAdapterEntry adapterEntry)
        {
            if (adapterEntry.Type != MqttAdapterTypes.Sonoff)
            {
                yield break;
            }

            var deviceArguments = _deviceArgumentFactory.CreateDeviceArgument(adapterEntry);

            foreach (var operation in _deviceOperationFactory.CreateAllDeviceOperations(deviceArguments))
            {
                yield return(operation);
            }
        }
        public DeviceArgument CreateDeviceArgument(MqttAdapterEntry mqttAdapterEntry)
        {
            var convertedArguments = mqttAdapterEntry.Arguments.ToObject <DeviceArgument>();

            if (string.IsNullOrWhiteSpace(convertedArguments.CommandPrefix))
            {
                convertedArguments.CommandPrefix = DefaultCommandPrefix;
            }

            if (string.IsNullOrWhiteSpace(convertedArguments.TelePrefix))
            {
                convertedArguments.TelePrefix = DefaultTelePrefix;
            }

            if (string.IsNullOrWhiteSpace(convertedArguments.StatPrefix))
            {
                convertedArguments.StatPrefix = DefaultStatPrefix;
            }

            return(convertedArguments);
        }