Wrong icon

Hi,

I’ve got an issue were the wrong icon is displayed, got this config for my bedscale:

binary_sensor:
#----------------------------------------------------------------
  - platform: template
    sensors:
      david_in_bed:
        friendly_name: "David in Bed"
        device_class: occupancy
        icon_template: mdi:hotel
        delay_on:
          seconds: 2
        delay_off: 
          seconds: 2
        value_template: >
          {{ states('sensor.bed_scale_weight')|int >= states('sensor.bed_scale_threshold') }}
      
      nele_in_bed:
        friendly_name: "Nele in Bed"
        device_class: occupancy
        icon_template: mdi:hotel
        delay_on:
          seconds: 2
        delay_off: 
          seconds: 2
        value_template: >
          {{ states('sensor.bed_scale_weight')|int > 4000000
            and (states('sensor.bed_scale_weight')|int < states('sensor.bed_scale_threshold')|int
                 or states('sensor.bed_scale_weight')|int >= 5500001)}}

But only Nele is getting the right icon?
Aantekening 2020-03-20 192755

Searched through the entire config, but can’t find anything which could overwrite the icon.

Also Lovelace config looks normal:

entities:
  - binary_sensor.david_in_bed
  - binary_sensor.nele_in_bed
show_header_toggle: false
title: Bedscale
type: entities

Any thoughts?

david_in_bed value template is wrong. Need to convert that last field to an int.

It’s possible that if it never changes state, it never updates the icon. In david’s case, the number might always be bigger than the string and wont update.

If you put an entity_id for it to track, it should at least change state when sensor.bed_scale_weight changes.

      david_in_bed:
        friendly_name: "David in Bed"
        device_class: occupancy
        entity_id: sensor.bed_scale_weight
        icon_template: mdi:hotel
        delay_on:
          seconds: 2
        delay_off: 
          seconds: 2
        value_template: >
          {{ states('sensor.bed_scale_weight')|int >= states('sensor.bed_scale_threshold') | int }}

Indeed, binary_sensor.david_in_bed wasn’t even working. Converting that last field to an int fixed the binary sensor, as well as the icon.

Jim, thanks for helping me with this. :slightly_smiling_face:

1 Like