public IEnumerable <DeviceOperation> CreateAllDeviceOperations(DeviceArgument deviceArgument) { yield return(CreateDeviceOperation(deviceArgument, OperationType.On)); yield return(CreateDeviceOperation(deviceArgument, OperationType.Off)); yield return(CreateDeviceOperation(deviceArgument, OperationType.Toggle)); }
public SonoffBrokerMessage CreateBrokerMessage(DeviceArgument deviceArgument, OperationType operationType) { if (deviceArgument is null) { throw new ArgumentNullException(nameof(deviceArgument)); } return(new SonoffBrokerMessage { Identifier = deviceArgument.Identifier, CommandPrefix = deviceArgument.CommandPrefix, Value = operationType.ToString() }); }
public DeviceOperation CreateDeviceOperation(DeviceArgument deviceArgument, OperationType type) { var brokerMessage = _brokerMessageFactory.CreateBrokerMessage(deviceArgument, type); return(new DeviceOperation() { Name = $"Sonoff:{deviceArgument.Identifier}:{type}", DisplayName = type.ToString(), Action = () => { _mqttInteractionService.SendMessage(brokerMessage); } }); }