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

Template Sensor Min/Max

$
0
0

@shauder wrote:

I am having to create template sensors to get battery level from my Wyze Sensors. This is great but I noticed some of them are reporting battery above 100. This doesn’t work as well with some cards like the bar graph cards.

I found I can create also a Filter sensor from my template sensors to set an upper and lower bound. This does exactly what I want but my question is there an easier way than creating a duplicate sensor using the Filter platform for sensors. Feels like a lot of extra YAML to manage when it could be just defined in the template sensors if it was an option?

EDIT: Nevermind, figured it out.

# Motion Sensors
    laundry_room_motion_battery_level:
      friendly_name: "Laundry Room Motion Battery Level"
      unit_of_measurement: '%'
      value_template: >-
        {% if state_attr('binary_sensor.motion_laundry_room', 'battery')|float > 100 %}
          100
        {% elif state_attr('binary_sensor.motion_laundry_room', 'battery')|float < 0 %}
          0
        {% else %}
          {{ state_attr('binary_sensor.motion_laundry_room', 'battery') }}
        {% endif %}

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



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