Skip to content

Commit

Permalink
Correctly handle   in names
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Jan 8, 2021
1 parent 152e9a7 commit ad6a3e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
16 changes: 10 additions & 6 deletions pyblnet/blnet_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,14 @@ def read_analog_values(self):
for match in match_iter:
match_dict = match.groupdict()
# convert html entities to unicode characters
for key in match_dict.keys():
for key, value in match_dict.items():
# replace   by " " since it is not unescaped as expected
value = value.replace(" ", " ")
if key == "value":
match_dict[key] = match_dict[key].replace(",", ".").replace(" ", "")
match_dict[key] = html.unescape(match_dict[key])
# also replace decimal "," by "." and remove " "
# for values
# also replace decimal "," by "." and remove " " completely
value = value.replace(",", ".").replace(" ", "")
match_dict[key] = html.unescape(value)
# and append formatted dict
data.append(match_dict)
return data
Expand Down Expand Up @@ -253,8 +256,9 @@ def read_digital_values(self):
for match in match_iter:
match_dict = match.groupdict()
# convert html entities to unicode characters
for key in match_dict.keys():
match_dict[key] = html.unescape(match_dict[key])
for key, value in match_dict.items():
value = value.replace(" ", " ")
match_dict[key] = html.unescape(value)
# and append formatted dict
data.append(match_dict)
return data
Expand Down
14 changes: 7 additions & 7 deletions pyblnet/tests/web_raw/web_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'unit_of_measurement': '°C',
'value': '24.6'},
7: {'id': '7',
'name': 'T\xa0Kaminofen',
'name': 'T Kaminofen',
'unit_of_measurement': '°C',
'value': '20.9'},
9: {'id': '9',
Expand All @@ -48,7 +48,7 @@
'value': 'AUS'},
7: {'id': '7',
'mode': 'AUTO',
'name': 'P\xa0Kaminofen',
'name': 'P Kaminofen',
'value': 'EIN'},
10: {'id': '10',
'mode': 'HAND',
Expand Down Expand Up @@ -92,7 +92,7 @@
},
7: {
'id': '7',
'name': 'T\xa0Kaminofen',
'name': 'T Kaminofen',
'value': '55.8',
'unit_of_measurement': '°C'
},
Expand Down Expand Up @@ -130,7 +130,7 @@
},
7: {
'id': '7',
'name': 'P\xa0Kaminofen',
'name': 'P Kaminofen',
'mode': 'AUTO',
'value': 'EIN'
},
Expand Down Expand Up @@ -159,7 +159,7 @@
'value': '-72.3'},
{'id': '6', 'name': 'Temp.Raum', 'unit_of_measurement': '°C', 'value': '24.6'},
{'id': '7',
'name': 'T\xa0Kaminofen',
'name': 'T Kaminofen',
'unit_of_measurement': '°C',
'value': '20.9'},
{'id': '9', 'name': 'TZirku.RL', 'unit_of_measurement': '°C', 'value': '36.6'}]
Expand Down Expand Up @@ -196,7 +196,7 @@
},
{
'id': '7',
'name': 'T\xa0Kaminofen',
'name': 'T Kaminofen',
'unit_of_measurement': '°C',
'value': '55.8'
},
Expand Down Expand Up @@ -230,7 +230,7 @@
}, {
'id': '7',
'mode': 'AUTO',
'name': 'P\xa0Kaminofen',
'name': 'P Kaminofen',
'value': 'EIN'
}, {
'id': '10',
Expand Down

0 comments on commit ad6a3e0

Please sign in to comment.