Getting entity state within entity card that belongs to another entity

Hi all,

What I’m doing wrong with this icon_color script?

Simply, if I’m trying to call the state of another entity besides the one assigned to the card - it doesn’t work.

- type: custom:mushroom-entity-card
       entity: sensor.khol_inside_temperature
       primary_info: state
       secondary_info: name
       name: Inside
       icon: mdi:home-thermometer
       badge_color: ''
       icon_color: >-
         {% set temp_out =
         states( 'sensor.khol_outside_temperature' )| float(0) %} 
         {% set temp_in=states(entity)|float(0) %}
         {% if temp_out < temp_in %} red {% elif temp_out > temp_in %} blue {% elif
         temp_out == temp_in %} yellow {% else %} grey {% endif %} 

Thanks in advance

You have to use the template card. custom:mushroom-entity-card doesn’t support templating.

Well, I’m blind. Thanks a lot

You could try using card-templater … it is a bit fiddly to get it to work and does not always work but …
Hereby an example from a gauge card to reduce the decimals and get a title from another sensor… >> example only…the content has no value itself

type: custom:card-templater
card:
  type: gauge
  entity: input_number.sunsetmin
  name_template: '{{ states(''sensor.06_weather_alert'') }}'
entities:
  - entity: input_number.sunsetmin
    state_template: '{{ states("input_number.sunsetmin") | int(0) }}'
1 Like