I would like to start an automation as soon as the temperature (see attached graph) increases after decline. See yellow marked spot. How to detect this properly and code this? Can someone point me in a good directon? T
Temperature is an entity measured by a netatmo sensor.
I was also thinking along this direction. I think some extra logic or config might be needed to avoid jitter (aka flapping) if the measurement is quite flat and to compensate for sensor noise. I would first filter the data to make it smoother.
Sure the provided example shows a smooth transition. But that isn’t always the case. If the temp rises then falls, cloud cover, rain, etc all impact this behaviour.
The trend sensor has ‘debouncing’ features such as samples and duration to prevent this.
Flapping, debouncing, jitter, sensor noise, etc.: I think a few people are trying to say the same thing, so I’ll try to answer this collectively: The data you posted seem fairly smooth in the highlighted part, but this may not always be the case. You probably don’t want to trigger immediately, because the larger trend might be going one way, but for a moment it could go in the other direction, so you’ll get a false positive (look at your initial post in the period between 15h00 and 19h00).
Before I learnt about the trend sensor Tinkerer posted, my suggestion was to smooth the data more before taking the derivative. With the trend sensor, you don’t need that part though (if I read the docs correctly): min_gradient will probably do the job. It does seem you’d need to set up 2 of these if you want to track both an upward and downward trend (from your initial post it seems you only need the former).
This is great Pieter. I am going to work both with the trend sensor and filter sensor. Use these to compare values…
About Filtering. For temperature sensor purposes, what filtering would you apply? The sensor on average gives a measurement every 9 mins… but sometimes this is missing. How to get one filtered line of data indicating the temperature for every point in time based on filter.
I would go for the lowpass option and pick a time_constant of 3 for starters. I don’t have enough experience with this particular integration to say how it will deal with missing values, but it might well be that it only looks at the state when the sensor is available. Practically, the 3 means it will take about 3 updates to get to the new value as the filtered value, if that new value is constant for the next 3 samples. For one update it will take 3 times 9 minutes, if you have a measurement available every time.
PS: A time constant of 2 in this case would be the same as a 2-sample moving average (the current and previous samples being weighed 50/50). A very high time constant basically means you give all the weight to the latest measurement.