Cool down - Get notified when night cooling via window opening is beneficial

Where I live there are currently daytime maximum temperatures above 30°C. At night, however, it is quite common that temperatures drop below the room air temperature, making night cooling possible. I can then open the windows and cool the rooms for free.

But when is the right time in the evening to open the windows for night cooling? That varies from day to day…

To solve this I created a template binary sensor (on when the room temperature is above 22°C and the outside temperature is one degree lower than the room temperature) which triggers a mobile phone notification. On the Sonoff Ns Wall Panels and the Lovelace Dashboard, I have created icons that are only conditionally displayed.

Surely there is a more elegant and clever solution than my presented below, but it’s a start. Have you also implemented something like this? I am curious what you think of it!

Template binary_sensor i added in configuration.yaml

template:
  - binary_sensor:
      - name: "Central Night Cooling OK"
        delay_on: 00:30:00 # to avoid toggling
        delay_off: 01:00:00 # to avoid toggling
        state: >
          {{ (states('sensor.room_temp_average') | float > 22) and (states('sensor.central_outside_temp') | float < (states('sensor.room_temp_average') | float - 1)) }}

Automation for notification on mobile phone

alias: Central Night Cooling Notification
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.central_night_cooling_ok
    to: "on"
condition: []
action:
  - service: notify.mobile_app_iphone
    data:
      title: Night Cooling possible
      message: Open Windows to cool down the rooms
mode: single

Dashboard with conditional icon in picture-elements card

type: picture-elements
image: /local/floorplan/floorplan.png
elements:
  - type: conditional
    conditions:
      - entity: binary_sensor.central_night_cooling_ok
        state: 'on'
    elements:
      - type: icon
        icon: mdi:weather-windy
        style:
          top: 10%
          left: 15%
          color: green

Sonoff Ns Panel

The display turns on via a presence sensor, so when I walk by, I see the icon and am reminded to open the windows. The UI is selfmade in the Nextion Editor and integrated via ESPHome.

text_sensor:
  - platform: homeassistant
    id: nightcooling
    entity_id: binary_sensor.central_night_cooling_ok
    on_value:
      then:
        - wait_until:
            switch.is_on: nextion_init    
        - lambda: |-
            int symbol=0; // symbol with question mark
            if (id(nightcooling).state == "on")
            {
              symbol = 44; // wind symbol
            }
            else
            {
              symbol = 31; // placeholder with background color
            }
            id(disp1).send_command_printf("Home.nightcooling.pic=%i", symbol);
4 Likes

This is cool, I’ve often thought of doing something similar as we have the same problem but haven’t got around to it. With summer on the way I’ll try setting up and post any feedback.

My bigger idea is to repurpose our heat transfer system which is rarely used. Have inlet bringing in outside air and through filter to be turned on when outside temp drops. Our biggest issue with opening windows is bugs come in at night.

where to add this binary sensor in yaml? this is the first for me.

Hi
Good question. I struggled with that as well at my first steps in Home Assistant a few month ago… You can add that portion of code to your configuration.yaml file. To do that easily, you need an editor which gives you the ability to edit that file via Home Assistants user interface. You could use e.g. the “File Editor” or “Studio Code Server” add-on to edit your configuration file.

Have a look at e.g. the following youtube video which gives a short introduction about templating and as well shows the installation of an editor Templates and Custom Sensors in Home Assistant - How To TUTORIAL. I personally learned a ton by watching such videos.

After watching this video you might asking about the Difference between “sensor platform Template” and “Template sensor ”.

Hope that helped to get you further.

yea, I figured it out after a few hours of searching. For me was to create a template.yaml file.

config:

template: !include template.yaml

template.yaml

  - binary_sensor:
      - name: "Central Night Cooling"
        delay_on: 00:30:00 # to avoid toggling
        delay_off: 01:00:00 # to avoid toggling
        state: >
          {{ (states('sensor.average_house_temperature') | float(0) > 22) and (states('sensor.oa_temperature') | float(0) < (states('sensor.average_house_temperature') | float(0) - 1)) }}

The dashboard also got me since I never setup a floor plan image. Figured that out as well. Created my first floorplan from scratch. Now, I just need to figure out how to use .css file for rotating icon without installing add on floorplan from HAC.