ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
345 stars 50 forks source link

[Feature Request] Add windows Management #7

Closed Djal94 closed 2 years ago

Djal94 commented 2 years ago

Thanks for the work. Please could you add management for windows please. (Turn off when windows is open).

Thanks

nagyrobi commented 2 years ago

That can be easily done using automations in Home Assistant...

Djal94 commented 2 years ago

of course

nagyrobi commented 2 years ago
group: 
  doors_and_windows:
    name: Any door or window
    entities:
      - binary_sensor.window1
      - binary_sensor.door1
      - ....
- id: heating_on_outside_temp
  trigger:
  - platform: state
    entity_id: 'group.doors_and_windows'
    to: 'off' #windows closed
  action:
  - service: climate.turn_on
    data:
      entity_id: climate.heater

- id: heating_off_outside_temp
  trigger:
  - platform: state
    entity_id: 'group.doors_and_windows'
    to: 'on' # windows open
  action:
  - service: climate.turn_off
    data:
      entity_id: climate.heater
ScratMan commented 2 years ago

@Djal94 if you mean window opening detection based on temperature drop, I'm not supporting such feature and no plan to support it. I tried it on connected thermostats from Netatmo and Tado, and it's not reliable at all. Such detection algorithm need very fast temperature drop to correctly detect that a window is opened. But this will depend on the indoor/outdoor temperature difference ; if the difference is too low, or if the drop rate is too slow due to external factors, the thermostat won't detect the window opening and just consider it needs to heat more. And as the algorithm takes several minutes to check the temperature behavior, while heating, the efficiency of the system is globally low.

I'm now using door/windows opening sensors instead, with an automation in HA to switch off my Netatmo thermostat/valve in the room if it's opened for more than 3 minutes. And the automation switches it back on when the window is closed for more than one minute. It's fast, it's reliable and efficient.

alias: Chauffage chambres - Gestion
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_damis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    to: 'off'
    from: 'on'
    for: '00:01:00'
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_damis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    to: 'on'
    from: 'off'
    for: '00:03:00'
condition:
  - condition: and
    conditions:
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.netatmo_couloir
            state: 'off'
            attribute: preset_mode
      - condition: time
        before: '17:00'
        after: '5:00:00'
action:
  - entity_id: climate.netatmo_chambre_d_amis
    service_template: |
      {% if is_state("binary_sensor.fenetre_chambre_damis", "on") %}
        climate.turn_off
      {% elif is_state("binary_sensor.fenetre_chambre_damis", "off") %}
        climate.turn_on
      {% endif %}
    data_template: {}
  - entity_id: climate.netatmo_chambre_d_apolline
    service_template: |
      {% if is_state("binary_sensor.fenetre_chambre_dapolline", "on") %}
        climate.turn_off
      {% elif is_state("binary_sensor.fenetre_chambre_dapolline", "off") %}
        climate.turn_on
      {% endif %}
    data_template: {}
  - entity_id: climate.netatmo_chambre_parentale
    service_template: |
      {% if is_state("binary_sensor.fenetre_chambre_parentale", "on") %}
        climate.turn_off
      {% elif is_state("binary_sensor.fenetre_chambre_parentale", "off") %}
        climate.turn_on
      {% endif %}
    data_template: {}
  - condition: template
    value_template: |
      {{trigger.to_state is not none and
        trigger.from_state is not none and
        trigger.to_state.state == 'off'}}
  - service: notify.notify
    data:
      message: clear_notification
      data:
        tag: template
        value_template: >
          {% if "{{trigger.entity_id}}" == "binary_sensor.fenetre_chambre_damis"
          %}
            "fenetre_amis"
          {% elif "{{trigger.entity_id}}" ==
          "binary_sensor.fenetre_chambre_parentale" %}
            "fenetre_parents"
          {% else %}
            "fenetre_amis"
          {% endif %}
mode: parallel
max: 10

I could even add another automation to notify me and my wife if the heating is enabled (during winter) and the window in a room is left opened for more than 15 minutes.

alias: Chauffage chambres - notifications
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_damis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    from: 'off'
    to: 'on'
    for: '0:15:00'
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_damis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    from: 'on'
    to: 'off'
    for: '0:01:00'
condition:
  - condition: and
    conditions:
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.netatmo_couloir
            attribute: preset_mode
            state: 'off'
      - condition: time
        before: '17:00'
        after: '5:00:00'
action:
  - service: notify.notify
    data:
      title: >
        {% if trigger.entity_id == "binary_sensor.fenetre_chambre_damis" %}
          Fenêtre chambre d'amis
        {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_dapolline"
        %}
          Fenêtre d'Apolline
        {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_parentale"
        %}
          Fenêtre parentale
        {% else %}
          Pas compris
        {% endif %}
      message: >
        {% if trigger.entity_id == "binary_sensor.fenetre_chambre_damis" %}
          {% if is_state("binary_sensor.fenetre_chambre_damis", "on") %}
            Il est temps de fermer la fenêtre de la chambre d'amis pour ne pas chauffer les moineaux.
          {% else %}
            clear_notification
          {% endif %}
        {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_dapolline"
        %}
          {% if is_state("binary_sensor.fenetre_chambre_dapolline", "on") %}
            Il est temps de fermer la fenêtre de la chambre d'Apolline pour ne pas chauffer les moineaux.
          {% else %}
            clear_notification
          {% endif %}
        {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_parentale"
        %}
          {% if is_state("binary_sensor.fenetre_chambre_parentale", "on") %}
            Il est temps de fermer la fenêtre de la chambre parentale pour ne pas chauffer les moineaux.
          {% else %}
            clear_notification
          {% endif %}
        {% else %}
          Pas compris
        {% endif %}
      data:
        ttl: 0
        priority: high
        tag: >
          {% if trigger.entity_id == "binary_sensor.fenetre_chambre_damis" %}
            fenetre_amis
          {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_dapolline"
          %}
            fenetre_apolline
          {% elif trigger.entity_id == "binary_sensor.fenetre_chambre_parentale"
          %}
            fenetre_parentale
          {% endif %}
        color: yellow
mode: parallel
max: 10