Example #1
0
        public static IServiceCollection AddZWave(this IServiceCollection services, Action <ZWaveConfig> configure)
        {
            var options = new ZWaveConfig();

            configure?.Invoke(options);

            if (options.Enabled)
            {
                services.TryAddSingleton <ZWaveConfig>(options);
                services.TryAddSingleton <IZWaveControllerAccessor, ZWaveControllerAccessor>();

                services.TryAddScoped(typeof(IZWaveSwitchRepository <,>), typeof(ZWaveSwitchRepository <,>));
                services.TryAddScoped(typeof(IZWaveSensorRepository <>), typeof(ZWaveSensorRepository <>));
                services.TryAddScoped(typeof(IZWaveThermostatRepository <,>), typeof(ZWaveThermostatRepository <,>));

                services.AdditionalSwitchConfiguration(o =>
                {
                    o.AddSwitch(typeof(IZWaveSwitchRepository <,>));
                    o.AddSensor(typeof(IZWaveSensorRepository <>));
                    o.AddThermostat(typeof(IZWaveThermostatRepository <,>));
                });
            }

            return(services);
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="zwave">The ZWaveController to use.</param>
 /// <param name="config">The config.</param>
 public ZWaveSensorRepository(IZWaveControllerAccessor zwave, ZWaveConfig config)
 {
     this.zwave  = zwave.Controller;
     this.config = config;
 }