From 78dc5dccc05901828944f580cdf0535ce43dc17c Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Sun, 22 Aug 2021 18:31:28 +0200 Subject: [PATCH] Add 3d printer power consumption --- configuration/configuration.yaml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/configuration/configuration.yaml b/configuration/configuration.yaml index 4ea4243..01fc424 100644 --- a/configuration/configuration.yaml +++ b/configuration/configuration.yaml @@ -325,19 +325,6 @@ sensor: port: 993 username: 'home-assistant@nerull7.info' password: !secret imap_password - # Fix 3d_printer power sensor - - platform: integration - source: sensor.3d_printer_power - name: energy_spent - unit_prefix: k - round: 2 -# - platform: filter -# entity_id: sensor.3d_printer_power -# filters: -# - filter: range -# lower_bound: 0 -# unit_prefix: k -# round: 2 binary_sensor: - name: Desktop @@ -550,3 +537,20 @@ input_number: max: 3 step: 1 icon: "mdi:weather-windy" + +template: + - sensor: + - name: "3d_printer_kWh" + friendly_name_template: "3D printer energy (Total)" + unit_of_measurement: "kWh" + state_class: measurement + device_class: energy + state: > + {% set power = states('sensor.3d_printer_energy') | float %} + {% if (power > 0) %} + {{ power }} + {% else %} + {{ states('sensor.3d_printer_kWh') }} + {% endif%} + attributes: + last_reset: '1970-01-01T00:00:00+00:00' \ No newline at end of file