Integration of three state window handle sensors HmIP SRH - danielperna84/hahomematic GitHub Wiki

Integration of three-state window handle sensors HmIP-SRH (by @Lateadapter)

Implementing Homematic type HmIP-SRH window handle sensors results in some difficulties because the HA environment is expecting binary sensors for window state integration. First tests were done with the „button-card“ as proposed by Ritchi: https://homematic-forum.de/forum/viewtopic.php?f=84&t=73678&hilit=farbe&start=10#p715498

Unfortunately such implementation will not work with other cards (i.e. „entity-filter“) or entity-groups mixed with other binary window-sensors as HMIP-SWDO-2. Precondition for following setups are HACS installations of „card-mod“ and „fontawesome“ by Thomas Loven: https://github.com/thomasloven/lovelace-card-mod, https://github.com/thomasloven/hass-fontawesome

Here will be used an entity-filter-card, which finally should show dedicated opening state and colorized icon of all required windows. Standard Icons will be replaced by customized types. Four different cases of implementation will be shown. All four cases are primary using the identical entity from Homematic.

Please note: for usage of samples below entities need to be renamed according own installation

image

Customized icons are storaged under „config/custom_icons/…“ according „hass-fontawesome“ integration.

image

The entity-filter-card looks as follows:

Windows closed:

image

case 1: entity standard integration from hahomematic

  • icon: standard from HA
  • icon_color: standard from HA (the card will NOT detect the OPEN case)
  • state_attribute: standard from sensor

case 2: entity modification directly within the card

  • icon: customized with „card-mod“
  • icon_color: customized with „card-mod“ (here by purpose the standard color)
  • state_attribute: standard from sensor
  • case 2 requires the most configuration effort for each individual card in frontend

case 3: entity modification partially by template sensor and directly within the card

  • icon: customized by template sensor
  • icon_color: customized with „card-mod“ (here by purpose the standard color)
  • state attribute: customized by template sensor (in that case just small letters)
  • case 3 only requires icon color definition for each individual card in frontend

case 4: entity modification only by template binary_sensor with 3 (!!!) different icons

  • icon: customized by template binary_sensor
  • icon_color: standard from HA
  • state_attribute: standard from HA
  • case 4 can be used without further customization in frontend; the only limitations are the two states BUT these are shown with 3 individual icons

Windows tilted:

image

Case 5 only as reference shows an opened window via Homematic binary sensor HMIP-SWDO-2 with customized icon defined in entities. In difference to case 1 the open stage is here also shown as icon_color.

image

Windows opened:

image

Card Configuration:

image

type: entity-filter
entities:
  - sensor.fenster_schlafzimmer_state
  - entity: sensor.fenster_schlafzimmer_state
    card_mod: null
    style: |
      :host {
        {% if is_state('sensor.fenster_schlafzimmer_state', 'open') %}
        --card-mod-icon-color: var(--state-active-color); --card-mod-icon: fapro:x-window-open-left;
        {% elif is_state('sensor.fenster_schlafzimmer_state', 'closed') %}
        --card-mod-icon-color: var(--state-icon-color); --card-mod-icon: fapro:x-window-closed;
        {% else %} --card-mod-icon-color: var(--state-active-color); --card-mod-icon: fapro:x-window-tilted;
        {% endif %}
       }
  - entity: sensor.fenster_sz_test_3
    card_mod:
      style: >
        :host { {% if is_state('sensor.fenster_sz_test_3', 'offen') %}
        --card-mod-icon-color: var(--state-active-color); {% elif
        is_state('sensor.fenster_sz_test_3', 'geschlossen') %}
        --card-mod-icon-color: var(--state-icon-color);  {% else %}
        --card-mod-icon-color: var(--state-active-color); {% endif %} }  
  - binary_sensor.fenster_sz_test_3_bin
  - sensor.fenster_badezimmer_state
  - sensor.fenster_kinderzimmer_ost_state
  - sensor.fenster_kinderzimmer_west_state
  - binary_sensor.fenster_az_eg_fenster_arbeitszimmer_state
  - binary_sensor.fenster_wc_state
state_filter:
  - closed
  - tilted
  - open
  - offen
  - geschlossen
  - gekippt
  - 'on'
  - 'off'
card:
  type: entities
  state_color: true
  title: Entity Filter Card

Remarks:

  • As color "--card-mod-icon-color:" might be used any color, however here by purpose were used the variables "var(--state-active-color)" and "var(--state-icon-color)" in order to be changed automatically in case of themes used.
  • the state attributes after "state_filter" are reqired to define entities, which should be shown in frontend. Here only for demonstration all possible attributes are activated.

Template Sensors:

case 3:

- sensor:
  - name: "Fenster-SZ_Test_3"
    state: >
        {% if is_state('sensor.fenster_schlafzimmer_state', 'open') %}
            offen
        {% elif is_state('sensor.fenster_schlafzimmer_state', 'closed') %}
            geschlossen
        {% else %}
            gekippt
        {% endif %}
    icon: >
        {% if is_state('sensor.fenster_schlafzimmer_state', 'open') %}
          fapro:x-window-open-left
        {% elif is_state('sensor.fenster_schlafzimmer_state', 'closed') %}
           fapro:x-window-closed
        {% else %}
           fapro:x-window-tilted
        {% endif %}

case 4:

- binary_sensor:
  - name: "Fenster-SZ_Test_3_bin"
    device_class: "window"
    state: >
        {% if is_state('sensor.fenster_schlafzimmer_state', 'open') %}
            on
        {% elif is_state('sensor.fenster_schlafzimmer_state', 'closed') %}
            off
        {% else %}
            on
        {% endif %}
    icon: >
        {% if is_state('sensor.fenster_schlafzimmer_state', 'open') %}
          fapro:x-window-open-left
        {% elif is_state('sensor.fenster_schlafzimmer_state', 'closed') %}
           fapro:x-window-closed
        {% else %}
           fapro:x-window-tilted
        {% endif %}

You may download the icons here: Window_Icons.zip