Seite 1 von 1
sensor - attribute_template - Property is not allowed
Verfasst: Sa 15. Jan 2022, 15:47
von PX80
Irgendwie komm ich nicht ganz klar mit YAML und deren Aufbau. Ich wollte gerade das Beispiel des Müllkalenders nachbauen
Siehe:
viewtopic.php?p=609#p609
bekomme aber folgenden Fehler:
Re: sensor - attribute_template - Property is not allowed
Verfasst: So 16. Jan 2022, 19:37
von Osorkon
Kannst Du bitte mal den Code als Code formatiert hier posten?
Danke und Gruß
Osorkon
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mo 17. Jan 2022, 15:49
von PX80
seltsam, nach einem StudioCodeServer Update, steht jetzt "Property platform not allowed".
Code: Alles auswählen
- platform: template
sensors:
restabfall:
friendly_name: Restabfall
value_template: >
{{ as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time")) | timestamp_custom('%d.%m.%Y') }}
icon_template: >-
{% if state_attr('sensor.restabfall', 'days_left') == 0 %}
mdi:delete-empty
{% else %}
mdi:delete-outline
{% endif %}
attribute_templates:
weekday: >
{{ as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time")) | timestamp_custom('%w') }}
text: >
{% if state_attr('sensor.restabfall', 'days_left') == 0 %}
Heute
{% elif state_attr('sensor.restabfall', 'days_left') == 1 %}
Morgen
{% else %}
in {{ state_attr('sensor.restabfall', 'days_left') }} Tagen
{% endif %}
color: >
{% if state_attr('sensor.restabfall', 'days_left') == 0 %}
color="#ff6347"
{% elif state_attr('sensor.restabfall', 'days_left') == 1 %}
color="#ffae00"
{% endif %}
days_left: >
{{ ((as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time"))-as_timestamp(states.sensor.date.state+' '+'00:00:00')) / 86400) | int }}
Ich habe mir noch den FileEditor geladen und da sieht alles gut aus OHNE Fehler.
Jedoch ist der Sensor - auch nach einem neustart - nicht verfügbar
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mo 17. Jan 2022, 18:59
von Hamudulu
Hallo
ist bei mir gleich, funktioniert aber alles trotzdem wie es soll....
auf Github wurde der Bug schon angezeigt, ne Lösung gibts aber noch nicht...
Warten wir ab.
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mo 17. Jan 2022, 19:06
von PX80
ok. aber hast du eine erklärung, warum der sensor bei mir nicht existiert?
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mo 17. Jan 2022, 21:45
von Hamudulu
Sorry, nicht auf die Schnelle. Ich bin selbst noch sehr unerfahren mit yaml und lern mich da grad selbst ein…
Re: sensor - attribute_template - Property is not allowed
Verfasst: Di 18. Jan 2022, 16:51
von Friedi
PX80 hat geschrieben: ↑Mo 17. Jan 2022, 19:06
ok. aber hast du eine erklärung, warum der sensor bei mir nicht existiert?
Was sagt denn das Log?
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mi 19. Jan 2022, 08:15
von PX80
welches Log genau muss ich mir anschauen? ( gerne auf der Kommandozeile )
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mi 19. Jan 2022, 09:25
von Friedi
PX80 hat geschrieben: ↑Mi 19. Jan 2022, 08:15
welches Log genau muss ich mir anschauen? ( gerne auf der Kommandozeile )
- Greenshot 2022-01-19 09.22.22.png (68.09 KiB) 1251 mal betrachtet
Mit Kommandozeile kann ich leider nicht dienen...
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mi 19. Jan 2022, 13:58
von PX80
keine einträge hinsichtlich des sensors
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mi 19. Jan 2022, 15:04
von Friedi
Dann wird er wohl aufgrund eines Code-Fehlers nicht erstellt
Re: sensor - attribute_template - Property is not allowed
Verfasst: Mi 19. Jan 2022, 15:16
von Friedi
Nur mal so, ist weekday wirklich ein Attribut? Es gibt die Funktion weekday(). Vielleicht gibt es da ein Problem wegen der Funktion.
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 08:46
von PX80
ich dachte das attribute wird damit angelegt oder muss es ein vorhandes attribute vom Kalender sein auf welchen sich der Sensor bezieht?
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 08:50
von Friedi
Falsch verstanden. Vielleicht gibt es reservierte Namen.
Kurz: Ich weiß es nicht.
Aber: Studio Code hat derzeit Bugs, Was zählt ist der File Editor, nur hat der halt nicht unbedingt die entsprechenden Hinweise. Syntaktisch scheint dein Code ja zu passen.
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 08:53
von Friedi
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 13:27
von PX80
ich gebs auf
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 14:38
von Friedi
Warum, was ist das Problem?
Artikel gelesen? Oder ist Englisch das Problem? Da könnte ich helfen.
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 16:29
von PX80
Es fehlen mir die Beispiele für mein YAML Layout. Ich versteh die Zusammensetzung im gesamten nicht .. also platform/template/sensor kombination
Re: sensor - attribute_template - Property is not allowed
Verfasst: Fr 21. Jan 2022, 18:42
von Friedi
Ausgehend von diesem Beispiel:
Code: Alles auswählen
template:
- sensor:
- name: "Sun Angle"
unit_of_measurement: "°"
state: >-
{{ '%.1f'|format(state_attr('sun.sun', 'elevation')) }}
attributes:
temp: >-
{{ '%.1f'|format(state_attr('sun.sun', 'elevation')) }}
würde ich das mal so testen:
Code: Alles auswählen
template:
- sensor:
- name: "restabfall"
state: >-
{{ as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time")) | timestamp_custom('%d.%m.%Y') }}
attributes:
weekday: >-
{{ as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time")) | timestamp_custom('%w') }}
text: >-
{% if state_attr('sensor.restabfall', 'days_left') == 0 %}
Heute
{% elif state_attr('sensor.restabfall', 'days_left') == 1 %}
Morgen
{% else %}
in {{ state_attr('sensor.restabfall', 'days_left') }} Tagen
{% endif %}
color: >-
{% if state_attr('sensor.restabfall', 'days_left') == 0 %}
color="#ff6347"
{% elif state_attr('sensor.restabfall', 'days_left') == 1 %}
color="#ffae00"
{% endif %}
days_left: >-
{{ ((as_timestamp(state_attr("calendar.calendar.abfallkalender", "start_time"))-as_timestamp(states.sensor.date.state+' '+'00:00:00')) / 86400) | int }}
Die Referenz steht ja auch da:
https://www.home-assistant.io/integrati ... te-sensors
Re: sensor - attribute_template - Property is not allowed
Verfasst: Sa 22. Jan 2022, 15:25
von PX80
bekomme leider damit ein fehler nach dem neustart
Invalid config
The following integrations and platforms could not be set up:
sensor
Please check your config and logs.
Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 12).
In configuration.yaml
Code: Alles auswählen
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensor.yaml
Re: sensor - attribute_template - Property is not allowed
Verfasst: Sa 22. Jan 2022, 15:42
von Friedi
Das ist klar.
Das ist ein Template und kein Sensor. Der Code (von mir) darf nicht in deine Sensor.yaml, sondern muss so in die config.yaml.
Re: sensor - attribute_template - Property is not allowed
Verfasst: Sa 22. Jan 2022, 16:52
von PX80
wie kann ich dann templates auslagern? dachte es sind nur externe dateien mit x-beliebigen namen um die config nicht zuzumüllen
PS: funktioniert nun. wie bekomm ich das ausgelagert?
Re: sensor - attribute_template - Property is not allowed
Verfasst: Sa 22. Jan 2022, 17:17
von Friedi
PX80 hat geschrieben: ↑Sa 22. Jan 2022, 16:52
wie kann ich dann templates auslagern? dachte es sind nur externe dateien mit x-beliebigen namen um die config nicht zuzumüllen
PS: funktioniert nun. wie bekomm ich das ausgelagert?
Ich habe das bei mir so gemacht:
Das verweist auf den Ordner template. In diesem Ordner kann ich dann beliebige YAML-files anlegen.
Re: sensor - attribute_template - Property is not allowed
Verfasst: So 23. Jan 2022, 08:12
von PX80
super. danke
Re: sensor - attribute_template - Property is not allowed
Verfasst: So 23. Jan 2022, 08:25
von Friedi
Gerne
Wenn du die Lösung als solche markierst, hilft es vielleicht anderen