Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion homeassistant/components/torque/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def get(self, request):
names[pid] = data[key]
elif is_unit:
pid = convert_pid(is_unit.group(1))
units[pid] = data[key]

temp_unit = data[key]
if "\\xC2\\xB0" in temp_unit:
temp_unit = temp_unit.replace("\\xC2\\xB0", "°")
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.

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

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.

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
Copy Markdown
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")


units[pid] = temp_unit
elif is_value:
pid = convert_pid(is_value.group(1))
if pid in self.sensors:
Expand Down