question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add icon or icon template to the sensors.

See original GitHub issue

Do you ever plan to add icons to sensors, better icon templates? Because now, after creating sensors, you have to create sensor templates and only add icons there.

multiscrape:
  - resource: https://www.home-assistant.io
    scan_interval: 3600
    sensor:
      - name: Latest version
        select: ".current-version > h1:nth-child(1)"
        value_template: '{{ (value.split(":")[1]) }}'
      - name: Release date
        select: ".release-date"
    binary_sensor:
      - name: Latest version == 2021.7.0
        select: ".current-version > h1:nth-child(1)"
        value_template: '{{ (value.split(":")[1]) | trim == "2021.7.0" }}'

sensor:
  - platform: template
    sensors:
      latest_version_good:
         friendky_name: Latest version
         value_template: '{{ states('sensor.latest_version') }}'
         icon_template: >-
             {% if is_state('sensor.latest_version', states('sensor.version')) %}
                 mid:movie-star-outline
             {% else %}
                 mid:history
             {% end if %}

binary_sensor:
  - platform: template
    sensors:
       latest_version_good:
          friendly_name: Latest version
          value_template: '{{ is_state('binary_sensor.latest_version', 'on') }}'
          icon_template: >-
             {% if is_state('binary_sensor.latest_version', 'on') %}
                mid:check-circle-outline
             {% else %}
                mid:checkbox-blank-circle-outline
             {% end if %}

After that, duplicate sensors appear with and without icons.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
danieldotnlcommented, Jun 20, 2021

I think it’s easier for binary sensors to provide a boolean as input for the icon template instead of a string. I’ll try to clarify the description. Thanks!

1reaction
danieldotnlcommented, Jun 19, 2021

Could you elaborate on your issue? Works for me: {% if value == True %}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Icon in a template sensor - Configuration
hi there, i have created a sensor for a hue motion sensor to add the battery ... The code is the same as...
Read more >
Using a Template to Change a Sensor's Icon in Home ...
The value_template , where you define the states of the sensor based on inputs; The icon_template , where you change the type of...
Read more >
Templates and Custom Sensors in Home Assistant - YouTube
Material Design Icons : https://materialdesignicons.com/ * How to ... to use a custom sensor in a Home Assistant dashboard 23:46 Add a custom ......
Read more >
Motion Sensor Icon - Dribbble
Discover 1 Motion Sensor Icon design on Dribbble. Your resource to discover and connect with designers worldwide.
Read more >
Template Sensor - Home Assistant 中文网
To enable Template Sensors in your installation, add the following to your ... (template)(Optional)Defines a template for the icon of the sensor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found