Hallo,
ich habe mir aus dem Web für mein Dasbhboard eine Karte für den Druckstatus meines 3D Drucker zusammengeklaubt.
Ohne diese Vorlage hätte ich es nicht hinbekommen.
Funktioniert soweit auch, nur die Druckzeit wird nicht angezeigt. Ich sehe zwar, das der Druck zur Uhrzeit x fertig sein soll. Ich möchte aber auch sehen, wieviele Minuten es dauert.Dieser Zeitraum wird mir in den Octoprint Daten ja auch unter Estimated Finish Time angezeigt.
Der Code sieht wie folgt aus:
- type: conditional
conditions:
- condition: state
entity: binary_sensor.octoprint_printing
state: 'on'
chip:
type: template
content: >-
{% set time = (states('sensor.octoprint_estimated_finish_time') |
int) | int %} {% set minutes = ((time % 3600) / 60) | int %} {% set
hours = ((time % 86400) / 3600) | int %} {% set days = (time /
86400) | int %}
{%- if time < 60 -%}
Less than a minute
{%- else -%}
{%- if days > 0 -%}
{{ days }}d
{%- endif -%}
{%- if hours > 0 -%}
{%- if days > 0 -%}
{{ ' ' }}
{%- endif -%}
{{ hours }}h
{%- endif -%}
{%- if minutes > 0 -%}
{%- if days > 0 or hours > 0 -%}
{{ ' ' }}
{%- endif -%}
{{ minutes }}m
{%- endif -%}
{%- endif -%}
icon: mdi:timer-outline
entity: sensor.octoprint_estimated_finish_time
tap_action:
action: more-info
hold_action:
action: navigate
navigation_path: /lovelace/3d-printer
card_mod:
style: |
ha-card {
--chip-background: --chip-background: rgba(var(--rgb-{{ config.icon_color }}), 0.1);
border: none;
}
- type: conditional
conditions:
- condition: state
entity: binary_sensor.octoprint_printing
state: 'on'
chip:
type: template
content: >-
{% if utcnow().day ==
as_datetime(states('sensor.octoprint_estimated_finish_time')).day%}
Today {{
as_timestamp(states('sensor.octoprint_estimated_finish_time')) |
timestamp_custom ('%H:%M') }} {% elif utcnow().day ==
as_datetime(states('sensor.octoprint_estimated_finish_time')).day -
1 %} Tmrw {{
as_timestamp(states('sensor.octoprint_estimated_finish_time')) |
timestamp_custom ('%H:%M') }} {% elif utcnow().day >
as_datetime(states('sensor.octoprint_estimated_finish_time')).day%}
{% else %} {{
as_timestamp(states('sensor.octoprint_estimated_finish_time')) |
timestamp_custom ('%b %d %H:%M') }} {% endif%}
icon: mdi:clock-check-outline
entity: sensor.octoprint_estimated_finish_time
tap_action:
action: more-info
hold_action:
action: navigate
navigation_path: /lovelace/3d-printer
card_mod:
style: |
ha-card {
--chip-background: --chip-background: rgba(var(--rgb-{{ config.icon_color }}), 0.1);
border: none;
}
Ich bin da leider ein absoluter Laie und komme nicht weiter:
Dah