Hello,
i have the following template, wich is not work. But, i dont know why. Can anyone explain me what i doing wrong?
strom_momentan is working
strom_momentan_temp is working
strom_seit_meldung issnt working
if i set “strom_seit_meldung” to only states(‘sensor.strom_gesamt’) i become the entry from “strom_gesamt”.
sensor:
- platform: mqtt
name: "strom_momentan"
state_topic: "strom/stromzaehler/strom"
unit_of_measurement: 'W'
qos: 1
# value_template: "{{(value|round(2))}}"
- platform: mqtt
name: "strom_gesamt"
state_topic: "test/stromzaehler/kwh"
unit_of_measurement: 'kWh'
qos: 1
value_template: "{{(value|round(0))}}"
- platform: template
sensors:
strom_momentan_temp:
friendly_name: "Stromverbrauch Momentan"
unique_id: strom_momentan_id
unit_of_measurement: 'W'
value_template: >-
{{ (3600000/(120*(states.sensor.strom_momentan.state)|round(2)))|round(2) }}
strom_seit_meldung:
friendly_name: "Stromverbrauch seit letzter Meldung"
unique_id: strom_gesamt_id
unit_of_measurement: 'kWh'
value_template: >-
{% set strom_json = {
"letzteMeldung": 175570,
"preiskwh": 0.293
} %}
{{ ((states('sensor.strom_gesamt') - strom_json.letzteMeldung) * strom_json.preiskwh) | round(2) }}
if i try this, the template “strom_seit_meldung” is unavaible in the dashboard sensor card.
Thank You very much. I try this the last hours…
schmucke