So, musste ans Laptop
Und so würde ich das nicht aufbauen...........
gutes Beispiel zum testen im "Template" von HA
mit einem Sensor von mir und dann passt es auch
ist alt aufgebaut eigentlich soll nach dem "float" ein "float(0)
das war aber nicht der Fehler! zwei Klammern fehlten!!!
habe deine komplette config grob bereinigt, also mal bitte so komplett übernehmen
Code: configuration.yaml
# Loads default set of integrations. Do not remove.
default_config:
#
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
#
# Text to speech
tts:
- platform: google_translate
#
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#
sensor:
- platform: template
sensors:
#
# Template sensor for values of power import (active_power > 0)
power_import:
friendly_name: "Power Import"
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) > 0 %}
{{ states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly_em3_channel_a_power'),
states('sensor.shelly_em3_channel_b_power'),
states('sensor.shelly_em3_channel_c_power')
] | map('is_number') | min
}}"
#
# Template sensor for values of power export (active_power < 0)
power_export:
friendly_name: "Power Export"
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) < 0 %}
{{ (states('sensor.shelly_em3_channel_a_power')|float + states('sensor.shelly_em3_channel_b_power')|float + states('sensor.shelly_em3_channel_c_power')|float) * -1 }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly_em3_channel_a_power'),
states('sensor.shelly_em3_channel_b_power'),
states('sensor.shelly_em3_channel_c_power')
] | map('is_number') | min
}}"
#
# Template sensor for values of power consumption
power_consumption:
friendly_name: "Power Consumption"
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shelly_em_channel_1_power')|float(0) - states('sensor.power_export')|float(0)) < 0 %}
{% elif (states('sensor.power_export')|float(0)) > 0 and (states('sensor.shelly_em_channel_1_power')|float(0) - states('sensor.power_export')|float(0)) > 0 %}
{{ (states('sensor.shelly_em_channel_1_power')|float(0)) - states('sensor.power_export')|float(0) }}
{% else %}
{{ states('sensor.power_import')|float(0) + states('sensor.shelly_em_channel_1_power')|float(0) }}
{% endif %}
#
#
# Template sensor for values of power import (active_power > 0)
power_import2:
friendly_name: "Power Import2"
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if (states('sensor.shelly_em3_channel_a_power')|float(0) +
states('sensor.shelly_em3_channel_b_power')|float(0) +
states('sensor.shelly_em3_channel_c_power')|float(0) -
states('sensor.shelly_em_channel_1_power')|float(0)) > 0 %}
{{ states('sensor.shelly_em3_channel_a_power')|float(0) +
states('sensor.shelly_em3_channel_b_power')|float(0) +
states('sensor.shelly_em3_channel_c_power')|float(0) -
states('sensor.shelly_em_channel_1_power')|float(0) }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly_em3_channel_a_power'),
states('sensor.shelly_em3_channel_b_power'),
states('sensor.shelly_em3_channel_c_power')
] | map('is_number') | min
}}"
#
# Template sensor for values of power export (active_power < 0)
power_export2:
friendly_name: "Power Export2"
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if (states('sensor.shelly_em3_channel_a_power')|float(0) +
states('sensor.shelly_em3_channel_b_power')|float(0) +
states('sensor.shelly_em3_channel_c_power')|float(0) -
states('sensor.shelly_em_channel_1_power')|float(0)) < 0 %}
{{ (states('sensor.shelly_em3_channel_a_power')|float(0) +
states('sensor.shelly_em3_channel_b_power')|float(0) +
states('sensor.shelly_em3_channel_c_power')|float(0) -
states('sensor.shelly_em_channel_1_power')|float(0)) *-1 }}
{% else %}
{{ 0 }}
{% endif %}
availability_template: "{{
[ states('sensor.shelly_em3_channel_a_power'),
states('sensor.shelly_em3_channel_b_power'),
states('sensor.shelly_em3_channel_c_power')
] | map('is_number') | min
}}"
Alles anzeigen