Skip to content

Footer/Header: Graph#5273

Merged
zsarnett merged 4 commits into
home-assistant:devfrom
zsarnett:graph-footer-header
Mar 23, 2020
Merged

Footer/Header: Graph#5273
zsarnett merged 4 commits into
home-assistant:devfrom
zsarnett:graph-footer-header

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

@zsarnett zsarnett commented Mar 19, 2020

Proposed change

Adds the graph from the sensor card as a Footer Header Option

image

Type of change

  • New feature (thank you!)

Example configuration

footer:
  entity: sensor.random_sensor
  type: graph
  detail: 1
  hours_to_show: 24

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

home-assistant/home-assistant.io#12492

@zsarnett
Copy link
Copy Markdown
Contributor Author

Error if not a sensor entity

image

Warning if not numeric

image

Should these be changed?


const stateObj = this.hass!.states[this._config.entity];

if (!stateObj.attributes.unit_of_measurement) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a unit_of_measurement for a line graph?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 100% sure. That's how we built it back when we built the sensor card. I tried a sensor with no UOM and received an error. but the state was also not a number.

Added in a catch for if the state history is undefined. That should catch this.

Comment thread src/panels/lovelace/header-footer/hui-graph-header-footer.ts Outdated
Comment thread src/panels/lovelace/header-footer/hui-graph-header-footer.ts Outdated
@zsarnett zsarnett merged commit ce92add into home-assistant:dev Mar 23, 2020
@zsarnett zsarnett deleted the graph-footer-header branch March 23, 2020 13:47
@lock lock Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants