Trying to access tibber power sensor

Hello,
im a newbee to homeassistant and getting in trouble to access tibber sensor power values.
i have in my configuration.yaml linked the template.yaml by template: !include template.yaml

in my template.yaml i have:

# Template-Sensoren
  - sensor:
    # Strom-Haus-Leistung-aktuell
    - name: Strom-Haus-Leistung-aktuell
      unique_id: StromHausLeistungAktuell
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      state: >
       {{ state.attr('sensor.tibber_pulse_HOMEID_energie', 'Watt') }}

HOMEID is replaced by a string of my adress.
Result:

but the sensor shows in “entwicklerwerkzeuge” developer tools: state unknown.

Test configuration.yaml leads to no errors.
What is wrong with my code? Has anybody an idea?
thanks a lot.

What I further want to do, when the tibber sensor works: have a dashboard for actual power and day-based energy and afterworfs i want to link the energy consumption of tibber with the my anker solix e1600 to set the output power to the actual consumption of tibber.

Has anybody also for this job a solution?!

thank you in advance!

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Ok, sorry - does it Look better now and does anybody has a solution available?

state_attr() not state.attr().

Thank you, but this wasn’t the error, because in my template.yaml is this inside:
Sorry for that additional error in the Post.

# Template-Sensoren
### Zeit und Datum
sensor:
  - name: Mein Datum
    unique_id: mein_datum
    icon: mdi:calendar-today          
    state: >
      {% set months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] %}
      {% set days = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"]  %}
      {{ days[now().weekday()] + ', ' + now().day | string + '.' + months[now().month-1] + ' ' + now().year | string }}
    # Strom-Haus-Leistung-aktuell
  - name: Strom-Haus-Leistung-aktuell
    unique_id: StromHausLeistungAktuell
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    state: >
      {{ state_attr('sensor.tibber_pulse_meta_frank_str_13_energie', 'Watt') }}
  - name: meine Zeit
    unique_id: meine_zeit
    icon: mdi:account-clock-outline
    state: >
      {{state_attr('sensor.date_time_iso') }} Uhr
#  - name: Datum Uhrzeit
#      {% set wochentag = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"] %}
#      {% set monat = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] %}
#      {% set wochentag = wochentag[now().weekday()] %}
#      {% set monat = monat[now().month - 1] %}  #      {{ wochentag }}, der {{ now().day }} {{ monat }} {{now().year}}

The only Thing what is working of his 3 Sensors is the date.
The Strom- Sensor still deliver “unknown”, but I don’t know why. Is there something else wrong?

The time sensor also has an encrypt in sensor.yaml:

- platform: time_date
  display_options:
    - 'date_time_iso'

Its not clearly to me why some Text is “cursiv” in the above post.

The time sensor only states “unavailable” in States understand development tools.

What is wrong with my time sensor?
Do I need an additional addon? I think date is working so time & date musst work both (no missing addon) - am I right?
Sorry for wasting ÿour time with stupid questions but some Essentials still miss after reading docu.

Found the solution by myself in:

  • errors:
    time & date not activated
    syntax error by calling states_attr() → must be: states()
    helpful: developer tools → template
# Template-Sensoren
### Zeit und Datum
- sensor:
  - name: Dashboard Datum und Zeit
    unique_id: datum_uhrzeit
    icon: mdi:calendar-today
    state: > 
      {% set months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] %}
      {% set days = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"] %}
      Heute ist {{ days[now().weekday()] + ', der ' + now().day | string + '. ' + months[now().month-1] }} und es ist {{ states('sensor.time') }} Uhr
  #Sensor Mein Datum
  - name: Mein Datum
    unique_id: mein_datum
    icon: mdi:calendar-today          
    state: >
      {% set months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] %}
      {% set days = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"]  %}
      {{ days[now().weekday()] + ', ' + now().day | string + '.' + months[now().month-1] + ' ' + now().year | string }}
  # Sensor Meine Zeit
  - name: meine Zeit
    unique_id: meine_zeit
    icon: mdi:account-clock-outline
    state: >
      {{states('sensor.time') }} Uhr
- sensor:
  - name: Strom-Haus-Leistung-aktuell
    unique_id: StromHausLeistungAktuell
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tibber_pulse_HOMEID_energie','Watt') }}