Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106179

Trying to create sensor with friendly Time

$
0
0

Hello,

I am trying to create a sensor which gives me a friendly time (hours and minutes) from another entity.
this is the sensor:

- sensor:
    - name: "Waschmaschinen Dauer schön"
      unique_id: "waschmaschine_dauer_schon"
      unit_of_measurement: min
      state_class: total
      device_class: timestamp
      state: >
        {% set hours = states('sensor.waschmaschine_dauer_year') | float %}
        {% set total_hours = hours | int %}
        {% set minutes = ((hours - total_hours) * 60) | round %}
        {{ total_hours }} St. {{ minutes }} Min.

In templating it works perfectly and gives me 106 St. 29 Min.
When I paste the code into a template.yaml package the sensor is not available.

What am I doing wrong?

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 106179

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>