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: []
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
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!
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!
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!
Changed topic title to english to avoid further german posts
Iâve done it
Thanks, great!
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.
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
Ah ok, that wonât work, sorry.
Please change your template.yaml to this:
- 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 %}
What I did was delete the first line (template:) and two spaces at the beginning of every row, so the indentation fits. And you already have template:
in your config.
Not important, just use the corrected version above. After saving you have to reload the config. Go to Developer tools > YAML
and first check your config by pressing the button in the first paragraph. If you get an ok, than reload template entites
with the button a little downwards. In german this is under Entwicklerwerkzeuge > YAML > Konfiguration prĂŒfen
and the secomnd one is called Template EntitÀten
.
Please report back, if everything works as expected.
All right, it works. Thank you
Sorry to bother, but may I ask for some guidance about this piece of code?
At the moment itâs driving me insane, that itâs not working as expected.
I added the
template: !include template.yaml
into the configuration.yaml, created a template.yaml and added the following code
- sensor:
- name: Esszimmer Balkontuer
state: |
{% set b1 = states('binary_sensor.esszimmer_balkontuer_oben_contact') %}
{% set b2 = states('binary_sensor.esszimmer_balkontuer_unten_contact') %}
{% if b1 == 'true' and b2 == 'true' %} geschlossen
{% elif b1 == 'false' and b2 == 'true' %} gekippt
{% elif b2 == 'false' and b1 == 'false' %} offen
{% elif b1 == 'unavailable' or b2 == 'unavailable' %} nicht verfĂŒgbar
{% else %} unbekannt
{% endif %}
icon: |
{% set b1 = states('binary_sensor.esszimmer_balkontuer_oben_contact') %}
{% set b2 = states('binary_sensor.esszimmer_balkontuer_unten_contact') %}
{% if b1 == 'true' and b2 == 'true' %} mdi:door-closed-variant
{% elif b1 == 'false' and b2 == 'true' %} mdi:angle-acute
{% elif b2 == 'false' and b1 == 'false' %} mdi:door-open-variant
{% elif b1 == 'unavailable' or b2 == 'unavailable' %} mdi:exclamation
{% else %} mdi:exclamation
{% endif %}
So, Iâm using Aqara Window/Door Sensors, attached to Zigbee2mqtt, which expose âcontactâ as state true or false. But, no matter if I use true/false in the code above or on/off, every time it creates the entity âsensor.esszimmer_balkontuerâ with the state âunbekanntâ.
Any advice from your side what Iâm doing wrong? Much appreciated.
Thanks in advance.
Regards
Sven
EDIT: Issue solved. It should be on/off and it seems I switched the state (off is closed and on is open) so it was an undefined state.
Hello and welcome to the community!
I see you got it solved for you!
Just to explain: if a binary_sensor
, like your Aqara sensors, has a device_class
, this is what makes it on/off, open/closed and so on.