Skip to content

Use unit system definitions for weather units#10657

Merged
bramkragten merged 6 commits intohome-assistant:devfrom
rianadon:backend-units
Dec 2, 2021
Merged

Use unit system definitions for weather units#10657
bramkragten merged 6 commits intohome-assistant:devfrom
rianadon:backend-units

Conversation

@rianadon
Copy link
Copy Markdown
Contributor

@rianadon rianadon commented Nov 19, 2021

Breaking change

Integrations that report their wind speed in km/h under the metric system will now display the wrong unit (the backend reports them as m/s). It might be worth waiting until the backend work of fixing unit conversion in the integrations is finished to merge this.

Proposed change

Now that wind speed and accumulated precipitation units have been added to the unit system, there is no longer any need to hard-code these in the frontend. These units are now taken directly from the unit system.

Also I made a PR in the websocket repo to add the types necessary for this: home-assistant/home-assistant-js-websocket#215.

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

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:

@balloob
Copy link
Copy Markdown
Member

balloob commented Nov 23, 2021

HAWS 5.11.3 released with your type update https://github.com/home-assistant/home-assistant-js-websocket/releases/tag/5.11.3

Comment on lines 156 to +162
case "pressure":
return lengthUnit === "km" ? "hPa" : "inHg";
return hass.config.unit_system.pressure || "";
case "wind_speed":
return `${lengthUnit}/h`;
return hass.config.unit_system.wind_speed || "";
case "visibility":
case "length":
return lengthUnit;
return hass.config.unit_system.length || "";
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.

Remove the case for pressure, wind_speed, and length as they can be handled by the default now.

@bramkragten bramkragten merged commit a6b5262 into home-assistant:dev Dec 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 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.

5 participants