Hello,
To detect the presence of my baby in her bed, I use two temperature sensors.
One under her mattress (sensor A), whose temperature rises when she’s in bed. A second, far from her (sensor B).
Next, I created a virtual sensor (sensor C) that subtracts sensor A from sensor B. If sensor C > 1°C, then I know my daughter is in bed.
Now I’d like to create trend sensors to track whether temperature of sensor C is increasing or decreasing. I need them to control the bedroom lights and speaker. If the temperature increases or is above 1°, my daughter is in bed and we turn everything on. If the temperature drops, she’s no longer in bed and everything has to be switched off.
My problem is about the trend sensors that don’t work as I’d like. I’ve tried configuring them with the following parameters:
- Trend sensor is up if the temperature rises by 0.5° over a time interval of 10 minutes.
- Sensor trend is up if the temperature rises by 0.6° over a 10-minute interval.
But as you can see from the annotated graph below, even very short micro variations (less than 10 minutes) counter-current point measurements distort the trend. I wish them not to influence the trends. And some trends are completely ignored, for example, the rise between 12 and 12.50.
Here is my configuration :
sensor:
- platform: template
ecart_temp_bed_child:
friendly_name: "Bed presence sensor"
unit_of_measurement: "°C"
value_template: >
{{ states('sensor.bed_baby_body_2')|float - states('sensor.bed_baby_temoin')|float }}
binary_sensor:
- platform: trend
sensors:
ecart_temp_baby_trend:
entity_id: sensor.ecart_temp_bed_child
friendly_name: Trend increasing
min_gradient: -0.0001
sample_duration: 600
- platform: trend
sensors:
ecart_temp_baby_trend_increase:
entity_id: sensor.ecart_temp_bed_child
friendly_name: Trend decreasing
min_gradient: 0.00083
sample_duration: 600
And here is a preview of results for today in Lovelace. I’ve added comments about things that are problematic for me:
I think there is something wrong with the configuration of my trend sensors. My point is of course to be able to turn off the speaker and the lights as soon as possible when the room is empty (I can’t take lullabies all day long ) but also to avoid false positives to prevent baby to awake accidentaly. Can someone help me improve my settings?
Thank you so much.