Example #1
0
        public static IHomeAssistantMqttConfigurationBuilder AddBinarySensor(
            this IHomeAssistantMqttConfigurationBuilder configurationBuilder,
            Func <IBinarySensorMqttEntityConfigurationBuilder, IBinarySensorMqttEntityConfigurationBuilder> configurator)
        {
            IBinarySensorMqttEntityConfigurationBuilder builder = new BinarySensorMqttEntityConfigurationBuilder();

            builder = configurator(builder);

            configurationBuilder.ServiceCollection.AddSingleton(sp =>
            {
                var entityConfiguration = builder.Build();
                return(entityConfiguration);
            });

            return(configurationBuilder);
        }
Example #2
0
        public static IHomeAssistantMqttConfigurationBuilder AddBinarySensor(
            this IHomeAssistantMqttConfigurationBuilder configurationBuilder,
            Func <IBinarySensorMqttEntityConfigurationBuilder, IBinarySensorMqttEntityConfigurationBuilder> configurator)
        {
            configurationBuilder.TryRegisterStatefulEntityBindingManager <IBinarySensorMqttEntityConfiguration, IBinarySensor, IBinarySensorEntityDefinition>();

            IBinarySensorMqttEntityConfigurationBuilder builder = new BinarySensorMqttEntityConfigurationBuilder();

            builder = configurator(builder);

            configurationBuilder.ServiceCollection.AddSingleton(sp =>
            {
                var entityConfiguration = builder.Build();
                return(entityConfiguration);
            });

            return(configurationBuilder);
        }