Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref: https://www.facebook.com/groups/homeassistantgroupefrance/posts/1341826740040898/ #1

Open
mathieucarbou opened this issue Oct 25, 2023 · 0 comments

Comments

@mathieucarbou
Copy link

image

Liberty_HA/sensors.yaml

Lines 539 to 545 in fb7ab38

- platform: template
sensors:
hue_motion_sensor_hall_battery_level:
friendly_name: "Hue Motion Sensor Hall Battery Level"
value_template: '{{state_attr("binary_sensor.capteur_couloir_motion", "battery_level")}}'
icon_template: '{%- if state_attr("binary_sensor.capteur_couloir_motion", "battery_level") <= 5 %}mdi:battery-outline{%- elif state_attr("binary_sensor.capteur_couloir_motion", "battery_level") >= 95 %}mdi:battery{% else %}mdi:battery-{{(state_attr("binary_sensor.capteur_couloir_motion", "battery_level")|float / 10)|round*10}}{%- endif %}'
unit_of_measurement: '%'

template:
  # https://www.home-assistant.io/integrations/sensor/
  - sensor:
      - name: Hue Motion Sensor Hall Battery Level
        state_class: measurement
        device_class: battery
        unit_of_measurement: "%"
        state: '{{state_attr("binary_sensor.capteur_couloir_motion", "battery_level")}}'

homeassistant:
  customize:
    sensor. hue_motion_sensor_hall_battery_level:
      templates:
        icon: >
          if state_attr("binary_sensor.capteur_couloir_motion", "battery_level") <= 5
              return 'mdi:battery-outline'
          if state_attr("binary_sensor.capteur_couloir_motion", "battery_level") >= 95
              return 'mdi:battery'
          return 'mdi:battery-' + state_attr("binary_sensor.capteur_couloir_motion", "battery_level")|float / 10)|round*10}}
        icon_color: >
          [...]

(not tested)

Ref: https://www.home-assistant.io/integrations/template/

image

Template declaration and UI / icons are separated. You can have everything in 1 file if you use packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant