Skip to content

fix: getEntityState() for "last" & "bar"#1322

Open
ildar170975 wants to merge 5 commits intokalkih:devfrom
ildar170975:bar-last
Open

fix: getEntityState() for "last" & "bar"#1322
ildar170975 wants to merge 5 commits intokalkih:devfrom
ildar170975:bar-last

Conversation

@ildar170975
Copy link
Copy Markdown
Collaborator

@ildar170975 ildar170975 commented Dec 12, 2025

Currently using "last" & "bar" causes a card to be not rendered due to an error.

type: custom:mini-graph-card
entities:
  - entity: sensor.system_monitor_processor_use
show:
  state: last
  graph: bar
image

It happens because "this.points" is not defined if graph type = "bar".

After the fix:
image

@ildar170975
Copy link
Copy Markdown
Collaborator Author

ildar170975 commented Dec 12, 2025

So we have 3 PRs to fix the same problem:

  1. fix: always get points so state last works with other graphs #1075 - "always define points".
  2. fix: state: last to use value from last Graph coordinate #1308 - "use coords"
  3. this one - "ether use points or bars".

Currently "points" & "bars" already have properly (I hope so) defined values.
So why not using these data instead?

Imho:

  1. Calculating "points" in case of bars is too "artificial".
  2. Using "coords" in "main()" is too "low level" because "coords" are inside a Graph object, I do not think we are supposed to use them directly in "main()".

@ildar170975 ildar170975 marked this pull request as ready for review December 12, 2025 05:12
@akloeckner akloeckner changed the base branch from master to dev December 14, 2025 07:48
@akloeckner
Copy link
Copy Markdown
Collaborator

Imho:

On the conceptual level, I'd agree. I'm wondering: will this fix also work, if show.points is false? (I think, that is a valid option, right?)

@ildar170975
Copy link
Copy Markdown
Collaborator Author

ildar170975 commented Mar 6, 2026

I'm wondering: will this fix also work, if show.points is false? (I think, that is a valid option, right?)

@akloeckner
Again, sorry for a delay.

  1. A "point" term is only applied to a "line" graph, not to a "bar".
  2. IMHO using together graph: line, show_points: false & state: last is wrong ))).
    See, the state: last means "show me a value of the last point", and by "points" we mean dots displayed on a curve.
    Since a curve is build using some algorithm, the "last point" in general could be not a "current state". In fact, any "point" may not contain a REAL value, only some interpolated one.
    (proposed some clarifications for Docs - docs: Add a remark regarding points #1346)
    So, if a user defined together graph: line, show_points: false & state: last - I would fallback to state: true, i.e. showing a current state.
    Added a commit for this fallback.

@ildar170975
Copy link
Copy Markdown
Collaborator Author

Additional changes:

  1. Added descriptions for getObjectAttr() & getEntityState() methods.
  2. In getEntityState(), an input argument id is renamed to index to be more consistent with other places.

@ildar170975
Copy link
Copy Markdown
Collaborator Author

Related - #1083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

State last fails to render card bug: state: last and graph: bar breaks graph rendering

2 participants