Skip to content

Ensure 0 does not get formatted to empty string#8971

Merged
bramkragten merged 2 commits intohome-assistant:devfrom
spacegaier:issue-8969
Apr 23, 2021
Merged

Ensure 0 does not get formatted to empty string#8971
bramkragten merged 2 commits intohome-assistant:devfrom
spacegaier:issue-8969

Conversation

@spacegaier
Copy link
Copy Markdown
Member

Breaking change

Proposed change

Currently a zero gets formatted to an empty string for number format "none". That should not happen as none means input = output value during formatting.

num is already ensured to be string or number in the function so no need to check for falsy during the return statement (I think?).

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

Additional information

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:

@spacegaier
Copy link
Copy Markdown
Member Author

@joshmcrty Are there use cases I am missing where the empty string was by design returned from the formatting logic?

@bramkragten bramkragten merged commit 899eab4 into home-assistant:dev Apr 23, 2021
@joshmcrty
Copy link
Copy Markdown
Contributor

@spacegaier I don't remember now why I added that check in the return statement. At some point there may have been a null or undefined value passed as the num value during my testing (even though there never should be). This is already merged, but if the issue comes up again we could either do a typeof check for those or use String(num) instead of num.toString() to avoid an error.

@spacegaier spacegaier deleted the issue-8969 branch April 23, 2021 14:03
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2021
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.

When forcasted templow/temperature is 0 - it only shows ° [card:weather-forecast]

4 participants