Gauge-Card, use other sensors as minimum/maximum

Hey,

I want to display a gauge card, where the min and max value should depend on two different sensors. (apex spot market prices and min/max of the day)

No matter what I try to reference the other sensors for min/max, upon saving it is always converted to "[object Object]": null

Any hints? My attempt:

type: gauge
entity: sensor.epex_spot_data_net_price
name: Current Price
min: 
  {{ states("sensor.epex_spot_data_lowest_price") }}
max: 
  {{ states("sensor.epex_spot_data_highest_price") }}

Very few core dashboard cards support templates, if they do they will say so in their documentation.

The gauge card does not.

There is a custom card that will enable you to do this though. See: đź“ť 100% Templatable Lovelace Configurations

1 Like

Ah thx.

Wasn’t aware, that not every card / property supports this.

Although config-template-card is a universal way to add templates - it is not recommended to use it in for the Gauge card. If you add a “needle” to the Gauge - it will “drop to 0” every time your sensor change.
Use auto-entities instead. Google in auto-entities main thread for “gauge”, I posted there a solution.

I was now able to use the config-template-card to achieve that.

Example: Show active lights of the total available lights in “garden”:

type: custom:config-template-card
entities:
  - sensor.garden_ccl_lights
  - sensor.garden_ccl_lights_on
card:
  type: gauge
  name: ${"Garten (" + states["sensor.garden_ccl_lights"].state * 1.0 + ")"}
  entity: sensor.garden_ccl_lights_on
  tap_action:
    action: call-service
    service: script.licht_garten_aus
  max: ${states["sensor.garden_ccl_lights"].state * 1.0}
  unit: an
  min: 0

As mentioned, during refresh, it drops to 0 before adjusting to the new value, but something I can live with in this usecase. (Tapping the gauge issues a “central-off” to the respective lights)

image

where each ccl-sensor (“CentralControlledLight”) is something like

{% set ccl_lights = label_entities('CentralControlLight') 
                    | select('match', 'light\.') 
                    | list %}
                    
{% set lights_floor = floor_areas('Garten') 
               | map('area_entities') 
               | sum(start=[]) 
               | select('match', 'light\.')
               | unique 
               | list %}

{% set ccl_lights_floor = set(ccl_lights).intersection(lights_floor) %}  

{{ ccl_lights_floor | length }}

showing the respective group or group_on values. _on uses one more select like

      {% set ccl_lights_on = set(ccl_lights_floor)
                          | select('is_state', 'on') 
                          | list %}