**Home Assistant release (`hass --version`):** `0.61.1`
**Python release (`…python3 --version`):** `Python 3.5.4`
**Component/platform:** Ecobee and MQTT Sensors
**Description of problem:**
When receiving data from sensors (some `mqtt`, some `ecobee`) with a `unit_of_measurement` that contains the degree symbol `°`, I get a `UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 438: ordinal not in range(128)` error.
The unit of measurement is accurately shown in the hass web frontend, and is accurately forwarded to InfluxDB
![screenshot-2018-1-17 grafana - house](https://user-images.githubusercontent.com/114193/35079479-05955f38-fbc5-11e7-8b18-f7d44bb4825e.png)
I've set `unit_of_measurement` to `F` for my `mqtt` sensors as a temporary workaround, but the `ecobee` sensors by-default produce this error.
**Expected:** If things are actually working - which they appear to be - less noise in the logs. If some functionality is not working because of this, to fix that.
**Problem-relevant `configuration.yaml` entries and steps to reproduce:**
Either of these:
1. Using the stock `ecobee` component
```yaml
ecobee:
api_key: !secret ecobee_api_key
```
2. Using a mqtt sensor as configured:
```yaml
sensor:
- platform: mqtt
state_topic: "environment/server_room/temperature"
unit_of_measurement: '°F'
name: "Server Room Temperature"
```
The `°` was inserted using `INSERT MODE -> CTRL+K -> SHIFT + G D`.
I've tried using vim to save, and iconv to convert, the file to the proper encoding, and neither gets rid of the error.
To reiterate, simply using the `ecobee` produces this error.
**Additional info:** Probably related to #9528
**Traceback (if applicable):**
```
INFO:homeassistant.components.ecobee:Ecobee data updated successfully
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: entity_id=climate.main_floor, new_state=<state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, old_state=<state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>>
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.5/logging/__init__.py", line 988, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 438: ordinal not in range(128)
Call stack:
File "/usr/home/kjohnson/homeassistant/bin/hass", line 11, in <module>
sys.exit(main())
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 366, in main
exit_code = setup_and_run_hass(config_dir, args)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
return hass.start()
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 158, in start
self.loop.run_forever()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
self._run_once()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 1425, in _run_once
handle._run()
File "/usr/local/lib/python3.5/asyncio/events.py", line 127, in _run
self._callback(*self._args)
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 321, in _wakeup
self._step()
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 240, in _step
result = coro.send(None)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 266, in async_update_ha_state
self.entity_id, state, attr, self.force_update)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 750, in async_set
'new_state': state,
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 406, in async_fire
_LOGGER.info("Bus:Handling %s", event)
Message: 'Bus:Handling %s'
Arguments: (<Event state_changed[L]: entity_id=climate.main_floor, new_state=<state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, old_state=<state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>>,)
DEBUG:homeassistant.components.websocket_api:WS 34582435544: Sending {'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'climate.main_floor', 'old_state': <state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, 'new_state': <state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 1, 18, 3, 21, 38, 293682, tzinfo=<UTC>)}, 'id': 2}
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.5/logging/__init__.py", line 988, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 522: ordinal not in range(128)
Call stack:
File "/usr/home/kjohnson/homeassistant/bin/hass", line 11, in <module>
sys.exit(main())
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 366, in main
exit_code = setup_and_run_hass(config_dir, args)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
return hass.start()
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 158, in start
self.loop.run_forever()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
self._run_once()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 1425, in _run_once
handle._run()
File "/usr/local/lib/python3.5/asyncio/events.py", line 127, in _run
self._callback(*self._args)
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 321, in _wakeup
self._step()
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 240, in _step
result = coro.send(None)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api.py", line 239, in _writer
self.debug("Sending", message)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api.py", line 224, in debug
_LOGGER.debug("WS %s: %s %s", id(self.wsock), message1, message2)
Message: 'WS %s: %s %s'
Arguments: (34582435544, 'Sending', {'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'climate.main_floor', 'old_state': <state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, 'new_state': <state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 1, 18, 3, 21, 38, 293682, tzinfo=<UTC>)}, 'id': 2})
DEBUG:homeassistant.components.websocket_api:WS 34681096736: Sending {'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'climate.main_floor', 'old_state': <state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, 'new_state': <state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 1, 18, 3, 21, 38, 293682, tzinfo=<UTC>)}, 'id': 2}
--- Logging error ---
Traceback (most recent call last):
File "/usr/local/lib/python3.5/logging/__init__.py", line 988, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 522: ordinal not in range(128)
Call stack:
File "/usr/home/kjohnson/homeassistant/bin/hass", line 11, in <module>
sys.exit(main())
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 366, in main
exit_code = setup_and_run_hass(config_dir, args)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/__main__.py", line 293, in setup_and_run_hass
return hass.start()
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 158, in start
self.loop.run_forever()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
self._run_once()
File "/usr/local/lib/python3.5/asyncio/base_events.py", line 1425, in _run_once
handle._run()
File "/usr/local/lib/python3.5/asyncio/events.py", line 127, in _run
self._callback(*self._args)
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 321, in _wakeup
self._step()
File "/usr/local/lib/python3.5/asyncio/tasks.py", line 240, in _step
result = coro.send(None)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api.py", line 239, in _writer
self.debug("Sending", message)
File "/usr/home/kjohnson/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api.py", line 224, in debug
_LOGGER.debug("WS %s: %s %s", id(self.wsock), message1, message2)
Message: 'WS %s: %s %s'
Arguments: (34681096736, 'Sending', {'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'climate.main_floor', 'old_state': <state climate.main_floor=heat; operation_mode=heat, operation=idle, current_temperature=71, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=off, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=off, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>, 'new_state': <state climate.main_floor=heat; operation_mode=heat, operation=heat, current_temperature=70, operation_list=['auto', 'auxHeatOnly', 'cool', 'heat', 'off'], supported_features=1457, actual_humidity=28, fan_min_on_time=0, aux_heat=on, climate_list=['Away', 'Home', 'Sleep', 'Work'], unit_of_measurement=\xb0F, temperature=71, min_temp=45, mode=Home, max_temp=95, fan=on, friendly_name=Main Floor, away_mode=off @ 2018-01-17T20:15:31.952584-07:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 1, 18, 3, 21, 38, 293682, tzinfo=<UTC>)}, 'id': 2})
```