Trend binary Sensor - inside vs outside temperature

I am looking to make an automation informing me I should close the windows if the outside temperature is rising, or open the windows if it starts falling.
The difficult part for me is to compare the outside temp with the inside temp.
I have a onewire thermometer and I am monitoring the house temp.
So, here is what I want to do:
example:
Inside temp is 25c
Outside temp is 23
IF:
outside temp starts rising for the last hour and is about to exceed / or already exceeded the inside temp
THEN:
close the windows

Same goes for the opposite.

This is messing with my head while I am trying to figure it out. It looks so simple, yet I cant even start making the automation.

If you already have a trend sensor binary_sensor.outside_temp_rising then this is pseudo code for your automation:

trigger 
	platform: state
		binary_sensor.outside_temp_rising = True
condition
	platform: template
		value_template: {{ sensor.outside_temp >= sensor.inside_temp }}
action
	close cover.window

Thank you! It works.
I am testing it for 2 days now and it is ok, but now my problem is that it is repeating itself. For example: when the outside temperature is already lower than the inside and stops droping, when it starts droping again, the automation is activated again. Any idea on how to prevent this?
I only want it to execute the automation only once.

I don’t understand. If it is dropping, then stops and again start dropping, the trend rising sensor will be False and the automation should not be triggered.

What am I missing?

I am not really sure. It is just what I noticed. When it stops dropping/rising and starts again after a while, I have the notification triggered again. Maybe I am the one missing something. Here, check it out for yourself:

3

This is my automations.yaml

- id: 'close windows'
  alias: '[Info] Temp Rising Close Windows'
  trigger:
  - entity_id: binary_sensor.temp_rising
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ states.sensor.owm_temperature.state >= states.sensor["280417a2e4d6ff_temperature"].state }}'
  action:
  - data:
      message: "Close the windows"
      title: "Custom subject"
    service: persistent_notification.create

and here is my binary_sensors.yaml

- platform: trend
  sensors:
    temp_falling:
      entity_id: sensor.owm_temperature
      sample_duration: 7200
      min_gradient: -0.0008
      device_class: cold

    temp_rising:
      entity_id: sensor.owm_temperature
      sample_duration: 7200
      min_gradient: 0.0008
      device_class: heat

You could have an input select ideal temperature.

too hot inside and colder outside.

If indoor > ideal and outdoor < indoor and windows = closed then notify user to open window.

too hot inside and even hotter outside.

If indoor > ideal and outdoor > indoor and windows = open then notify user to close Windows.

Etc.

To prevent repeat notifications.

Have input Boolean notified today.

Condition to run script is input Boolean is off.
On notify also turn unit Boolean on.

Set separate automation to turn input Boolean off at 8am each day.

You could do a separate input bolean already notified for both rising and falling notifications.

1 Like

This works great, but havent put it in the frontend yet. I am still trying to see how to fit it and the truth is, I dont have much time to do it. I was just messing around with my configuration today and bumped into my trend sensor. I have 2 sensors to read. Do you guys think I can make them into one by using a template sensor? I tried some combinations with β€œif” but I am not very good at this.
I also want to use icons.

The goal is to have only one sensor to see the temp rising or falling, The sensor should show an arrow showing up if it is rising, one showing down if falling and a dash if idle.

Edit: Nevermind, I got it.

- platform: template
  sensors:
    outsidetemptrend:
          value_template: >-
            {% if is_state('binary_sensor.temp_rising', 'on') %}
              Rising
            {% elif is_state('binary_sensor.temp_falling', 'on') %}
              Falling
            {% else %}
              Idle
            {% endif %}
          icon_template: >-
            {% if is_state('binary_sensor.temp_rising', 'on') %}
              mdi:arrow-up-bold
            {% elif is_state('binary_sensor.temp_falling', 'on') %}
              mdi:arrow-down-bold
            {% else %}
              mdi:minus
            {% endif %}
1 Like