Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Units of measurement are inappropriately determined in getUnit #25

Open
im-batman opened this issue Aug 13, 2019 · 0 comments
Open

Units of measurement are inappropriately determined in getUnit #25

im-batman opened this issue Aug 13, 2019 · 0 comments

Comments

@im-batman
Copy link

In ui/weather-card.js, several units of measurement are decided based upon whether lengthUnit is set to "km" -- which assumes that the provided data are either all metric or all imperial. The default weather source for hass.io is met.no, which supports mixed metric and imperial data. The result is that the Lovelace weather forecast card (https://www.home-assistant.io/lovelace/weather-forecast/) shows air pressure (which is provided in mbar by the data source) as inHg instead.

Each measurement needs to have its own associated unit tied to the unit of the original data source, particularly air pressure in this instance.

weather-card.js:304:

  getUnit(measure) {
    const lengthUnit = this.hass.config.unit_system.length;
    switch (measure) {
      case "air_pressure":
        return lengthUnit === "km" ? "hPa" : "inHg";
      case "length":
        return lengthUnit;
      case "precipitation":
        return lengthUnit === "km" ? "mm" : "in";
      default:
        return this.hass.config.unit_system[measure] || "";
    }
  }
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

No branches or pull requests

1 participant