kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
3.01k stars 234 forks source link

show_state: false does not hide the state #889

Closed MayeulC closed 9 months ago

MayeulC commented 1 year ago

I was thinking the readme lacked an example for state_map, so I was building one by replicating the "thermostat" card from lovelace, which seemed to be a common request:

image

This is the yaml code:

type: custom:mini-graph-card
name: Bedroom thermostat
hours_to_show: 24
points_per_hour: 60
decimals: 1
entities:
  - entity: climate.bedroom
    attribute: temperature
    name: target
    line_width: 1
    color: purple
    show_points: false
    show_legend: false
    show_fill: false
    show_state: false
    smoothing: false
  - entity: climate.bedroom
    attribute: current_temperature
    name: temperature
    show_state: true
  - entity: climate.bedroom
    attribute: hvac_action
    y_axis: secondary
    color: orange
    smoothing: false
    show_legend: false
    show_line: false
    show_points: false
state_map:
  - value: idle
    label: off
  - value: heating

And the result: image

As you can see, this is almost ready to be used as an example (it may be a bit too long and may be more fitting in a wiki page).

The one issue I encounter is the following: since I wanted the target temperature to be in the background, I specified it first. However, I would prefer to have the current_temperature displayed as the state. Unfortunately, hiding the state does not seem to be working for the first entity, as shown in the screenshot.

Displaying it works for the second entity, however.

rogersmj commented 1 year ago

Ha, I was trying to do the exact same thing, and ran into the same problem. The show_state option on entities doesn't seem to be fully working. I want the current temperature to be shown as the state, but I want it to be the third graph, so it's on "top" -- but this doesn't seem to be possible because of the bug with show_state.

- type: custom:mini-graph-card
  name: Main floor thermostat
  show:
    labels: true
    labels_secondary: false
  points_per_hour: 60
  hours_to_show: 24
  decimals: 1
  smoothing: false
  entities:
    - entity: climate.main_floor_thermostat
      attribute: target_temp_high
      color: "var(--google-blue)"
      show_fill: false
      show_legend: false
      show_state: false
    - entity: climate.main_floor_thermostat
      attribute: target_temp_low
      color: red
      show_fill: false
      show_legend: false
      show_state: false
    - entity: climate.main_floor_thermostat
      attribute: current_temperature
      name: Temperature
      color: "var(--google-green)"
      show_fill: false
      show_state: true
      smoothing: true
    - color: gray
      entity: climate.main_floor_thermostat
      attribute: hvac_action
      name: Heat (main)
      show_line: false
      show_fill: true
      show_points: false
      show_legend: false
      y_axis: secondary
  state_map:
    - value: idle
      label: Off
    - value: heating
      label: On

image

That "76 F" shouldn't be there, and the "70 F" should be on the left.

rogersmj commented 1 year ago

@kalkih Have you had a chance to look at this? I thought I might try to help but I'm a bit out of my depth when it comes to getting this running in such a way that I can develop against it, still working on that.

ildar170975 commented 9 months ago

There is no need to post a complex code with lots of unrelated things, it distracts people from the main issue.

Assume we need to hide the 1st state & show the 2nd state. Consider this short:

type: custom:mini-graph-card
entities:
  - entity: sensor.xiaomi_cg_1_co2
    show_state: false
  - entity: sensor.xiaomi_cg_2_co2
    show_state: true

image The 1st state is shown anyway.

What it was suggested is to allow hiding a state for the 1st entity. In this particular simple case it may only be done by hiding both states:

type: custom:mini-graph-card
entities:
  - entity: sensor.xiaomi_cg_1_co2
  - entity: sensor.xiaomi_cg_2_co2
show:
  state: false

image

This is by a design. Not a bug. The 1st placeholder - for the 1st entity.

You still may customize it by card-mod: hide the 1st state + show the 2nd state, or move the 2nd state to the place of the 1st state (easy!). Ask in HA community mini-graph-card thread.

FR https://github.com/kalkih/mini-graph-card/issues/972 - is about defining the "primary entity", which COULD BE an alternative to "indexes".

Closing this issue.