Two window sensors one output | Zwei Fenstersensoren eine Ausgabe

Hallo danke,

das scheint zu funktionieren. Da ich unterwegs bin konnte ich es nur mit dem Handy testen, da erscheint nun so ein Bild

siehe ganz unten. Evtl. liegt es auch an meinem gewählten Sensoren. Muss ich morgen am PC schauen.

Danke.

Gruß Werner

Hallo,

habe nun nochmals alles geprüft. Die Lösung ist genial.
Vielen, vielen Dank.

Nur noch zwei Fragen:

  1. Ist es einfach möglich die Symbole von allen Fenstern die nicht geschlossen sind gelb zu färben?
    2.Wenn ich alle Fenster so eingefügt habe, dann ist meine configuration.yaml sehr voll. Könnte man alle Fenstersensoren z.B. in eine fenstersensoren.yaml auslagern?

Nochmals herzlichen Dank. Wie kann man diese Programiersprache nur so verstehen?

Gruß Werner

Hi there,

have now checked everything again. The solution is awesome.
Thanks alot.

Just two more questions:

  1. Is it easy to color the symbols of all windows that are not closed yellow?
  2. When I have inserted all windows like this, then my configuration.yaml is very full. Could all window sensors be outsourced, for example in a window sensors.yaml?

Again thank you very much. How can you understand this programming language in that way?

Greetings Werner

As far as I know, there is no possibility to color the icon of a custom sensor. But you can adjust your theme.

It’s possible to outsource your sensors but be aware that all sensors have to go to the other file. Because you can’t duplicate sensor:

sensor: !include sensoren.yaml

sensor: 
  …
  

For a more adjustable split you could use directories (I’m doing it by using packages):

homeassistant:
  packages: !include_dir_named pakete

(„pakete“ is just an example)

In this new directory you can put unique files (and other directories), for example

fenstersensoren.yaml
tueren.yaml
telegram.yaml (if you want to outsource more than just sensors)

Hallo und vielen Dank.

die Auslagerung habe ich soweit verstanden und würde mich bei Problemen nochmals melden.
Mit dem Einfärben (Thema) werde ich mich auch beschäftzigen.

Das Hauptziel ist auf jedenfall erreicht.

Vielen Dank.

Gruß Werner

Hello and thank you very much.

I have understood the outsourcing as far as possible and would contact me again if there were any problems.
I will also deal with the coloring (topic).

The main goal has definitely been achieved.

Thanks very much.

Greetings Werner

I’m curious: When you click on your profile (last entry in sidebar menu), what is set under „theme“?

Hi there,

“Backend-Select” is selected.

Greetings Werner

Hallo,

da ist “Backend-Select” ausgewählt.

Gruß Werner

Then the colors should work. Strange.

The colors also work normally. The symbols only remain blue for the newly created window sensors

Normal funktionieren die Farben auch. Nur bei den neu erstellten Fenstersensoren bleiben die Symbole blau.

I was wrong. Also the default theme can’t change the colors of a custom sensor in a generic frontend card. What a pity.

Hi there,

no problem. If this does not work, I will display all open or tilted windows on a map. I use this system for this:
🔹 Auto-entities - Automatically fill cards with entities

Unfortunately, I still can’t do that either.
Tried to select “fensterstatus” as Entities - that also worked.
However, if I enter “offen” as the “State”, it doesn’t work.

I changed the sensor code a bit, for example:

      fensterstatus_schlafzimmer_dg:
        friendly_name: Fenster Schlafzimmer-DG
        value_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} gekippt
          {% elif b2 == 'on' %} offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
          {% else %} ?
          {% endif %}
        icon_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
          {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
          {% elif b2 == 'on' %} mdi:window-open-variant
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
          {% else %} ?
          {% endif %}

Greetings Werner

Hallo,

kein Problem. Wenn es so nicht geht, werde ich mir alle offenen oder gekippten Fenster in einer Karte anzeigen lassen. Ich nutze dazu dieses System:

Leider bekomme ich auch das noch nicht hin.
Habe versucht als Entities fensterstatus zu wählen - das hat auch funktioniert.
Jedoch wenn ich als “State” z.B. “offen” eingebe, da funktioniert es nicht.

Den Sensorencode habe ich noch etwas geändert, z.B.:

      fensterstatus_schlafzimmer_dg:
        friendly_name: Fenster Schlafzimmer-DG
        value_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} gekippt
          {% elif b2 == 'on' %} offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
          {% else %} ?
          {% endif %}
        icon_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_007cf906_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_698aff06_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
          {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
          {% elif b2 == 'on' %} mdi:window-open-variant
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
          {% else %} ?
          {% endif %}

Gruß Werner

Sorry it works, with this code:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*fensterstatus*'
      state: '*offen*'
  exclude: []

But how can I define a state as offen or gekippt?

Sorry es funktioniert doch, mit diesem Code:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*fensterstatus*'
      state: '*offen*'
  exclude: []

Aber wie kann ich als state offen oder gekippt definieren?

My first success.

It works like this:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*fensterstatus*'
      state: '*offen*'
    - entity_id: '*fensterstatus*'
      state: '*gekippt*'
  exclude: []

Mein erster Erfolg.

Es funktioniert so:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*fensterstatus*'
      state: '*offen*'
    - entity_id: '*fensterstatus*'
      state: '*gekippt*'
  exclude: []
1 Like

Who did you work that?

I have do a new card but nothing would show? I have one entity_id for open and one for gekippt.

I would show it on the card if its open or gekippt or closed.

Hi there,

so i ended up in the l:

type: custom:auto-entities
card:
  type: entities
  title: Offene Fenster
  state_color: true
  show_header_toggle: false
filter:
  include:
    - entity_id: '*fensterstatus*'
      state: offen
    - entity_id: '*fensterstatus*'
      state: '*offen oder gekippt*'
    - entity_id: '*fensterstatus*'
      state: gekippt
    - entity_id: '*fensterstatus*'
      state: '*nicht*'
    - entity_id: '*fensterstatus*'
      state: '?'
  exclude:
    - entity_id: '*fensterstatus*'
      state: '*geschlossen*'
sort:
  method: friendly_name


Greetings Werner

thx for this piece of code!

Hello

I’ll take a look here, I did the same thing as you before and changed your code so that it fits. I created a template.yaml with this text. Of course the commando is also stored in the Config.yaml.

- sensor:
    - name: Fensterstatus_Esszimmer_Links
      value_template: |
        {% set b1 = states('binary_sensor.esszimmer_fenster_links_gekippt') %}
        {% set b2 = states('binary_sensor.esszimmer_fenster_links_offen') %}
        {% if b1 == 'off' and b2 == 'off' %} geschlossen
        {% elif b1 == 'on' and b2 == 'off' %} gekippt
        {% elif b2 == 'on' and b1 == 'on' %} offen
        {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
        {% else %} ?
        {% endif %}
      icon_template: |
        {% set b1 = states('binary_sensor.esszimmer_fenster_links_gekippt') %}
        {% set b2 = states('binary_sensor.esszimmer_fenster_links_offen') %}
        {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
        {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
        {% elif b2 == 'on' and b1 == 'on' %} mdi:window-open-variant
        {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
        {% else %} ?
        {% endif %}

but he doesn’t make a sensor with it as an error message he tells me

Invalid configuration for template in template.yaml, line 12: icon_template is an invalid option for template, check: sensor->0->icon_template Invalid configuration for template in template.yaml, line 2: Required key “state” not specified. Invalid configuration for template in template.yaml, line 3: value_template is an invalid option for template, check: sensor->0->value_template

I don’t know what else I have to write where, I’m pretty new to HA

Greetings Timo

1 Like

Hallo Timo und willkommen im Forum!

Dies hier ist ein rein englisches Forum, daher ist es hier nicht nur Usus, sondern Pflicht, in englisch zu schreiben! Das hat verschiedene Gründe, wie z.B. dass alle Benutzer die Einträge ohne Übersetzungstool lesen können sollen!

Daher editiere bitte Deinen Beitrag und übersetze ihn auf englisch.

Desweiteren nutze bitte entsprechende Formatierungen für Deinen Code, es ist so schlicht nicht möglich, bestimmte Fehler zu sehen, da YAML sehr kritisch mit Leerzeichen und Einrückungen ist (welche ohne Formatierung verloren gehen).

Zu beidem findest Du hier entsprechende Hinweise:

Vielen Dank dafür! :slight_smile:

Die Fehlermeldung besagt übrigens, dass Du eine falsche Konfiguration verwendest, auf den ersten Blick sieht es nach einer Mischung zwischen altem und neuem Template Format aus. Dazu gerne mehr, nachdem Du den Beitrag geändert hast!

Vielen Dank nochmal und bitte nicht böse sein, aber bei so einem grossen Forum müssen ein paar Regeln sein! :slight_smile:


Hello Timo and welcome to the forum!

This is an english only forum, that’s why it’s not only a wish, but rather a requirement to post in english.This has different reasons, one of them being that all users should be able to read posts without the use of a translation tool.

Please edit your post and translate it to english.

And please format your code, this way it’s not possible to see some errors, as YAML is very picky with whitespace and indentations (which will be lost without proper formatting).

See here for both:

Thanks a lot!

Btw. the error message you get tells you, that you are trying to use a wrong configuration. On a first glance, it looks like it’s a mix of old and new template format. More on that, after you edited your post.

Again, thanks a lot, and please don’t take this as rude, but in a forum, big as this one, some rules are required! :slight_smile:


Changed topic title to english to avoid further german posts

I’ve done it

1 Like

Thanks, great! :slight_smile:

The sensor cannot be set up, because you’re mixing old and new format for template sensors.

The dash in front of sensor shows, you’re trying to use the new format, but unfortunately the keys you use, are from the old format. The old format uses value_template and icon_template, where the new format has state and icon instead. :slight_smile:

In this case you can use the new format, which would be like this:

template:
  - sensor:
    - name: Fensterstatus_Esszimmer_Links
      state: |
        {% set b1 = states('binary_sensor.esszimmer_fenster_links_gekippt') %}
        {% set b2 = states('binary_sensor.esszimmer_fenster_links_offen') %}
        {% if b1 == 'off' and b2 == 'off' %} geschlossen
        {% elif b1 == 'on' and b2 == 'off' %} gekippt
        {% elif b2 == 'on' and b1 == 'on' %} offen
        {% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfügbar
        {% else %}  unbekannt
        {% endif %}
      icon: |
        {% set b1 = states('binary_sensor.esszimmer_fenster_links_gekippt') %}
        {% set b2 = states('binary_sensor.esszimmer_fenster_links_offen') %}
        {% if b1 == 'off' and b2 == 'off' %} mdi:window-closed-variant
        {% elif b1 == 'on' and b2 == 'off' %} mdi:angle-acute
        {% elif b2 == 'on' and b1 == 'on' %} mdi:window-open-variant
        {% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
        {% else %} mdi:exclamation
        {% endif %}

I’m not exactly sure, what you mean by this:

How did you implement it in your config? If you have problems here, please post both files, configuration.yaml and template.yaml.

I created this entry in config.yaml

template: !include template.yaml

Then I created a template.yaml. This now contains your changed text