public void Setup() { Options = new MqttSourceOptions { Server = "wayne-foundation.com", Port = 1863, Password = "******", Username = "******", Topics = new Topics { Command = "cmnd/tasmota-dimmer/color", Result = "stat/sonoff-1144-dimmer-5/RESULT", } }; var clientOptions = new MqttClientOptionsBuilder() .WithTcpServer(Options.Server, Options.Port) .WithCredentials(Options.Username, Options.Password).Build(); MqttClientOptions = new ManagedMqttClientOptionsBuilder() .WithClientOptions(clientOptions) .Build(); MqttClientTcpOptions = clientOptions.ChannelOptions as MqttClientTcpOptions; }
public ISource[] GetSources() { Logger.Info($"Configuring {Configuration.Sources.Count()} sources"); return(Configuration.Sources.Select <SourceOptions, ISource>(sourceOptions => sourceOptions switch { MqttSourceOptions options => new MqttSource(options, new MqttFactory().CreateManagedMqttClient()), OpenRGBSourceOptions options => new OpenRGBSource( options, GetOpenRGBClientInstance(options.Server, options.Port), Observable.Interval(TimeSpan.FromMilliseconds(options.PollingInterval ?? 1000)) ), _ => throw new NotImplementedException($"Source for type {sourceOptions.Type} not implemented") }).ToArray());