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

Fix torque degree char #26183

Merged
merged 3 commits into from
Sep 18, 2019
Merged

Conversation

roblandry
Copy link
Contributor

Breaking Change:

None

Description:

When sensors are added to home-assistant, those with degree symbols are shown as \\xC2\\xB0 instead of °. This PR corrects the symbol.

Related issue (if applicable):
None. Created a PR instead of issue. :-)

Pull request with documentation for home-assistant.io (if applicable):
None

Example entry for configuration.yaml (if applicable):

Nothing changes

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please run black from the project root:

black --fast homeassistant


temp_unit = data[key]
if "\\xC2\\xB0" in temp_unit:
temp_unit = temp_unit.replace("\\xC2\\xB0", "°")
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it possible to solve this by applying the correct encoding at some point in the flow after receiving the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I am not a proficient python coder, and this was the only way i was able to correct the units. The posted url is a query string with these characters. Seeing as how this was left effectively broken, I tinkered until I found a working solution. I'm all ears if you have a cleaner solution.

Copy link
Contributor

@tsvi tsvi Sep 16, 2019

Choose a reason for hiding this comment

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

Can you check if the following would fix your issue:

units[pid] = data[key].decode("utf-8")

@MartinHjelmare MartinHjelmare added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Sep 12, 2019
@MartinHjelmare
Copy link
Member

Do we have another suggestion or should we merge?

@MartinHjelmare MartinHjelmare changed the title Torque degree char fix Fix torque degree char Sep 14, 2019
Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

This is fine, I think that's JSON encoding. Let's merge and see where it goes from there.

@balloob balloob merged commit 873d331 into home-assistant:dev Sep 18, 2019
@MartinHjelmare MartinHjelmare removed the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Sep 18, 2019
@lock lock bot locked and limited conversation to collaborators Sep 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants