If I understand your need correctly then this works:
var notification = _sensor.Publish(ps => ps
.Select(x => x >= 15.0)
.DistinctUntilChanged()
.Select(p => p
? Observable.Empty<double>()
: Observable
.Timer(TimeSpan.FromMinutes(1.0))
.Select(x => -1.0)
.IgnoreElements()
.Concat(ps))
.Switch());
I have assumed that _sensor
is an IObservable<double>
.
So this observable will publish all values from the _sensor
stream so long as the values have remained below 15.0 for at least one minute. I have tested this functionality.
My test code is:
var random = new Random();
var _sensor = Observable.Generate(
0,
x => true,
x => x,
x => random.NextDouble() * 16.0,
x => TimeSpan.FromSeconds(random.NextDouble()));
var published_sensor = _sensor.Publish();
var notification = published_sensor.Publish(ps => ps
.Select(x => x >= 15.0)
.DistinctUntilChanged()
.Select(p => p
? Observable.Empty<double>()
: Observable
.Timer(TimeSpan.FromSeconds(5.0))
.Select(x => -1.0)
.IgnoreElements()
.Concat(ps))
.Switch());
published_sensor.Merge(notification).Timestamp().Dump();
published_sensor.Connect();
The results I got are:

Note that 5 seconds pass before duplicate values are published and the duplicates stop when the source produces a value over 15.