Zwei Fenstersensoren eine Ausgabe

All good. You can copy it in your configuration.yaml.

Hallo,

wenn ich das einfĂŒge bekomme ich nach einem Neustart folgende Fehlermeldungen:

 Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:692
Integration: Sensor (documentation, issues)
First occurred: 16:16:16 (3 occurrences)
Last logged: 17:10:22
Updating octoprint sensor took longer than the scheduled update interval 0:00:30


 Logger: homeassistant.config
Source: config.py:464
First occurred: 16:11:17 (8 occurrences)
Last logged: 17:10:11

    Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 139).
    Invalid config for [automation]: [template] is an invalid option for [automation]. Check: automation->template. (See /config/configuration.yaml, line 12).
    Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 138).

Gruß Werner

Hi there,

when I insert this I get the following error messages after a restart:

 Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:692
Integration: Sensor (documentation, issues)
First occurred: 16:16:16 (3 occurrences)
Last logged: 17:10:22
Updating octoprint sensor took longer than the scheduled update interval 0:00:30


 Logger: homeassistant.config
Source: config.py:464
First occurred: 16:11:17 (8 occurrences)
Last logged: 17:10:11

    Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 139).
    Invalid config for [automation]: [template] is an invalid option for [automation]. Check: automation->template. (See /config/configuration.yaml, line 12).
    Invalid config for [template]: required key not provided @ data['sensor'][0]['state']. Got None. (See /config/configuration.yaml, line 138).


Greetings Werner

Would you please so kind and post your configuration.yaml?

Hallo,
gern, ich hoffe ich habe alle Zugangsdaten entfernt.

Gruß Werner

Hi there,
gladly, I hope I have removed all access data.

Greetings Werner

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

frontend:
  themes: !include_dir_merge_named themes
  
# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Test Garagentor Cover
cover:
  - platform: template
    covers:
      garage_door:
        friendly_name: "Garagentor mit Pfeilen"
        device_class: garage
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        open_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        close_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        stop_cover:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off

camera:
   - platform: onvif
     host: 
     port: 
     username: 
     password: 
     extra_arguments: -rtsp_flags none -rtsp_transport udp -q:v 2
     name: Rundum
     
alarm_control_panel:
  - platform: manual
    name: 
    code:
    arming_time: 10
    delay_time: 20

# Gruppe Hauptlich KĂŒche
light:
  - platform: group
    name: Hauptlicht KĂŒche
    entities:
      - light.lc10_paulmann_level_light_color_on_off
      - light.lc11_paulmann_level_light_color_on_off
      - light.lc12_paulmann_level_light_color_on_off

# Gruppe Ambientlicht KĂŒche
  - platform: group
    name: Ambientlicht KĂŒche
    entities:
      - light.iluminize_hk_zd_rgbcct_a_5878befe_level_light_color_on_off
      - light.iluminize_hk_zd_rgbcct_a_44ada7fe_level_light_color_on_off
      
# Telegram Bot anbindung
telegram_bot:
  - platform: polling
    api_key: 
    allowed_chat_ids:
      - 
      
notify:
  - name: HA_Message
    platform: telegram
    chat_id: 
    

# Datum und Uhrzeit    
sensor:
  - platform: template
    sensors:
      datum_zeit_time:
        friendly_name: ""
        value_template: >
          {% set days = ['Mo.', 'Di.', 'Mi.', 'Do.', 'Endl.Fr.', 'Sa.', 'So.'] %}
          {{ days[now().weekday()] }}
          {{ now().strftime('%d.%m. - %H:%M') }}  Uhr

# Einbindung Octoprint
octoprint:
  host: 
  api_key: 
  
  
# EntitÀten verbinden Gargentor (Test)
switch:
  - platform: template
    switches:
      garage_door:
        friendly_name: "Garagentorschalter"
        value_template: "{{ is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone', 'on') }}"
        turn_on:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        turn_off:
          service: light.toggle
          entity_id: light.ewelink_zb_sw01_1e1c6b22_on_off
        icon_template: >-
          {{ 'mdi:garage' if is_state('binary_sensor.tk04_sonoff_turkontakt_ias_zone','off') else 'mdi:garage-open' }}

# LĂŒfter SZ-KG EIN AUS 
  - platform: command_line
    switches:
      luefterszkg:
        command_on: "/usr/bin/curl -X GET http://192.168.178.72/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.72/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: LĂŒfter SZ-KG
      luefterwzdg:
        command_on: "/usr/bin/curl -X GET http://192.168.178.39/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.39/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: LĂŒfter WZ-DG
      luefterszmoritz:
        command_on: "/usr/bin/curl -X GET http://192.168.178.79/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.79/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: LĂŒfter SZ-Moritz
      lueftermoritz:
        command_on: "/usr/bin/curl -X GET http://192.168.178.71/?power=on"
        command_off: "/usr/bin/curl -X GET http://192.168.178.71/?power=off"
        value_template: '{{ value == "1" }}'
        friendly_name: LĂŒfter Moritz


template:
  - sensor:
      - unique_id: fensterstatus_kueche
      - name: Status KĂŒchenfenster
        state: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b460d606_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b095e406_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} Fenster KĂŒche geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} Fenster KĂŒche gekippt
          {% elif b2 == 'on' %} Fenster KĂŒche offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} Fenster KĂŒche nicht verfĂŒgbar
          {% else %} ?
          {% endif %}
        icon: |

          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b460d606_on_off') %}
          {% set b2 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b095e406_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 %}


Seems that your legacy template sensor and my example („modern“ method) clash.

This is my example built in legacy design:


      fensterstatus_kueche:
        friendly_name: Status KĂŒchenfenster
        value_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b460d606_on_off') %}
          {% set b2 = states('binary_sensor. lumi_lumi_sensor_magnet_aq2_b095e406_on_off') %}
          {% if b1 == 'off' and b2 == 'off' %} Fenster KĂŒche geschlossen
          {% elif b1 == 'on' and b2 == 'off' %} Fenster KĂŒche gekippt
          {% elif b2 == 'on' %} Fenster KĂŒche offen
          {% elif b1 == 'unavailable' or b2 == 'unavailable' %} Fenster KĂŒche nicht verfĂŒgbar
          {% else %} ?
          {% endif %}
        icon_template: |
          {% set b1 = states('binary_sensor.lumi_lumi_sensor_magnet_aq2_b460d606_on_off') %}
          {% set b2 = states('binary_sensor. lumi_lumi_sensor_magnet_aq2_b095e406_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 %}


Copy it under the last line of your sensor datum_zeit_time.

1 Like

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!