ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
336 stars 48 forks source link

Simplifying integration of Open Windows detection #132

Closed dominig closed 1 year ago

dominig commented 1 year ago

Describe the bug No where any easy information is provided to integrate an open window detection.

To Reproduce

  1. Check all documentation , nothing anywhere Expected behaviour Open window detection is an expected feature of a good heating integration. I rely on simple open window detection, as solution based on temperature drop are unreliable and slow.

I would have expected to find a description on how to setup my system to Away and how to resume it to previous are at least know status.

Screenshots I finally, after reading some python code, in particular, the import statements, have found a method using the base climate services. Unfortunately I am not sure that is works as UI feedback is misbehaving (see issue #131)

Would be nice to get lines in the Readme.md about the best model to benefit of the Generic Thermostat in HASsmartThermostat in the context of that use case :-)

alias: Window Bedroom Opened Stop heating
description: Set the heating to Away mode when window is opened
trigger:
  - type: opened
    platform: device
    device_id: a856b646ae1ff52860c226fe9ca67583
    entity_id: binary_sensor.kitchen_window1_iaszone
    domain: binary_sensor
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - service: climate.set_preset_mode
    data:
      preset_mode: away
    target:
      area_id: chambre
mode: single

alias: Window Bedroom Closed Activate heating
description: Set the heating to Confort mode when window is closed
trigger:
  - type: not_opened
    platform: device
    device_id: a856b646ae1ff52860c226fe9ca67583
    entity_id: binary_sensor.kitchen_window1_iaszone
    domain: binary_sensor
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - service: climate.set_preset_mode
    data:
      preset_mode: confort
    target:
      area_id: chambre
mode: single

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

ScratMan commented 1 year ago

Hi, window management is much more flexible using HA automations rather than locking a behaviour inside the thermostat's code. I'm personally using the following automation to manage my thermostats in the bedrooms, switching them off individually if corresponding window is opened more than 3mn ; notify me when the window is left open more than the specified delay during the day (I keep the heater on with lower temperature during the night even with window open) ; switch the thermostat back on when the window is closed for 1mn, and clear the notification. This is conditioned by the heating being enabled (main thermostat being on).

alias: Chauffage chambres - Gestion
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_dadonis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    to: "off"
    from: "on"
    for:
      hours: 0
      minutes: 1
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_dadonis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    to: "on"
    from: "off"
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.netatmo_couloir
            state: "off"
            attribute: preset_mode
      - condition: time
        before: "17:00:00"
        after: "5:00:00"
action:
  - entity_id: climate.chambre_adonis
    service_template: |
      {% if is_state("binary_sensor.fenetre_chambre_dadonis", "on") %}
        climate.turn_off
      {% elif is_state("binary_sensor.fenetre_chambre_dadonis", "off") %}
        climate.turn_on
      {% endif %}
    data_template: {}
  - entity_id: climate.chambre_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.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.mobile_app_pixel_6_pro
    data:
      message: clear_notification
      data:
        tag: template
        value_template: >
          {% if "{{trigger.entity_id}}" ==
          "binary_sensor.fenetre_chambre_dadonis" %}
            "fenetre_amis"
          {% elif "{{trigger.entity_id}}" ==
          "binary_sensor.fenetre_chambre_parentale" %}
            "fenetre_parents"
          {% else %}
            "fenetre_amis"
          {% endif %}
  - service: notify.mobile_app_pixel_6
    data:
      message: clear_notification
      data:
        tag: template
        value_template: >
          {% if "{{trigger.entity_id}}" ==
          "binary_sensor.fenetre_chambre_dadonis" %}
            "fenetre_amis"
          {% elif "{{trigger.entity_id}}" ==
          "binary_sensor.fenetre_chambre_parentale" %}
            "fenetre_parents"
          {% else %}
            "fenetre_amis"
          {% endif %}
mode: parallel
max: 10
alias: Chauffage chambres - notifications
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_dadonis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 10
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.fenetre_chambre_dadonis
      - binary_sensor.fenetre_chambre_dapolline
      - binary_sensor.fenetre_chambre_parentale
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.netatmo_couloir
            attribute: preset_mode
            state: "off"
      - condition: time
        before: "17:00:00"
        after: "5:00:00"
action:
  - service: notify.mobile_app_pixel_6_pro
    data:
      title: >
        {% if trigger.entity_id == "binary_sensor.fenetre_chambre_dadonis" %}
          Fenêtre chambre d'Adonis
        {% 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_dadonis" %}
          {% if is_state("binary_sensor.fenetre_chambre_dadonis", "on") %}
            Il est temps de fermer la fenêtre de la chambre d'Adonis 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_dadonis" %}
            fenetre_adonis
          {% 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
        target:
          - null
  - service: notify.mobile_app_pixel_6
    data:
      title: >
        {% if trigger.entity_id == "binary_sensor.fenetre_chambre_dadonis" %}
          Fenêtre chambre d'Adonis
        {% 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_dadonis" %}
          {% if is_state("binary_sensor.fenetre_chambre_dadonis", "on") %}
            Il est temps de fermer la fenêtre de la chambre d'Adonis 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_dadonis" %}
            fenetre_adonis
          {% 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
        target:
          - null
mode: parallel
max: 10