Skip to content

Sensor card update to copy fill feature#4745

Merged
balloob merged 1 commit into
home-assistant:devfrom
zsarnett:sensor-card
Feb 5, 2020
Merged

Sensor card update to copy fill feature#4745
balloob merged 1 commit into
home-assistant:devfrom
zsarnett:sensor-card

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

@zsarnett zsarnett commented Feb 4, 2020

Proposed change

This PR updates the Core Sensor card to mimic the fill feature of the Custom Graph Card

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

detail: 1
entity: sensor.outside_humidity
graph: line
type: sensor

Additional information

PR also moves the icon to the right side. Updates some CSS and CSS classes

  • Link to documentation pull request: Soon

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:

@zsarnett
Copy link
Copy Markdown
Contributor Author

zsarnett commented Feb 4, 2020

image

Comment thread src/panels/lovelace/cards/hui-sensor-card.ts Outdated
Comment on lines -94 to +110
history.forEach((item, i) => getCoords(item, i, 0, detail));
for (let i = 0; i < history.length; i += 1) {
getCoords(history[i], i, 0, detail);
}
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 this change?

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.

This is for when there isn't enough history to fill the hours requested. The previous method would start the line in the middle of the card if there were only 12 hours of data when 24 were requested

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.

Might be me, but I don't see a difference in what it does, just a more difficult way to write the same ;-)

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.

image

The difference using the previous method. For loop starts at 0 and loops through no matter if the item is []. For Each ignores NULL/Undefined/[] items

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.

Therefore i starts at ex. 14. Meaning the first X value is 14 * xRatio

@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 5, 2020

Please don't force push after reviews have started, it prevents us from spotting the changes.

@balloob
Copy link
Copy Markdown
Member

balloob commented Feb 5, 2020

🎉 🐬 🎉 🐬 🎉 🐬

@balloob balloob merged commit 107f428 into home-assistant:dev Feb 5, 2020
@zsarnett zsarnett deleted the sensor-card branch February 5, 2020 00:12
@lock lock Bot locked and limited conversation to collaborators Feb 6, 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