heyajohnny / cryptoinfo

Provides Home Assistant sensors for all cryptocurrencies supported by CoinGecko
GNU General Public License v3.0
49 stars 14 forks source link

UnicodeEncodeError #31

Closed pinthenet closed 1 year ago

pinthenet commented 2 years ago

Since uppgrading to HASS 2022.7.1 I get the following exception from cryptoinfo.

Logger: homeassistant.components.recorder.core
Source: components/recorder/core.py:725
Integration: Recorder (documentation, issues)
First occurred: 14:03:20 (4 occurrences)
Last logged: 14:03:40

Error while processing event EventTask(event=<Event state_changed[L]: entity_id=sensor.cryptoinfo_main_wallet_ethereum_eur, old_state=None, new_state=<state sensor.cryptoinfo_main_wallet_ethereum_eur=unknown; last_update=None, volume=None, baseprice=None, change=None, market_cap=None, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo ethereum eur @ 2022-07-10T14:03:10.005395+02:00>>): 'charmap' codec can't encode character '\u200b' in position 106: character maps to <undefined>
Error while processing event EventTask(event=<Event state_changed[L]: entity_id=sensor.cryptoinfo_main_wallet_bitcoin_eur, old_state=None, new_state=<state sensor.cryptoinfo_main_wallet_bitcoin_eur=unknown; last_update=None, volume=None, baseprice=None, change=None, market_cap=None, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo bitcoin eur @ 2022-07-10T14:03:10.005952+02:00>>): 'charmap' codec can't encode character '\u200b' in position 106: character maps to <undefined>
Error while processing event EventTask(event=<Event state_changed[L]: entity_id=sensor.cryptoinfo_main_wallet_ethereum_eur, old_state=<state sensor.cryptoinfo_main_wallet_ethereum_eur=unknown; last_update=None, volume=None, baseprice=None, change=None, market_cap=None, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo ethereum eur @ 2022-07-10T14:03:10.005395+02:00>, new_state=<state sensor.cryptoinfo_main_wallet_ethereum_eur=1159.4; last_update=10-07-2022 14:03, volume=8345345141.293325, baseprice=1159.4, change=-2.6199256861899443, market_cap=138693937879.98978, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo ethereum eur @ 2022-07-10T14:03:40.358985+02:00>>): 'charmap' codec can't encode character '\u200b' in position 164: character maps to <undefined>
Error while processing event EventTask(event=<Event state_changed[L]: entity_id=sensor.cryptoinfo_main_wallet_bitcoin_eur, old_state=<state sensor.cryptoinfo_main_wallet_bitcoin_eur=unknown; last_update=None, volume=None, baseprice=None, change=None, market_cap=None, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo bitcoin eur @ 2022-07-10T14:03:10.005952+02:00>, new_state=<state sensor.cryptoinfo_main_wallet_bitcoin_eur=20878.0; last_update=10-07-2022 14:03, volume=24645875011.95154, baseprice=20878, change=-1.0550779092237446, market_cap=398682497101.3022, unit_of_measurement=​, device_class=monetary, icon=mdi:bitcoin, friendly_name=Cryptoinfo bitcoin eur @ 2022-07-10T14:03:40.461864+02:00>>): 'charmap' codec can't encode character '\u200b' in position 162: character maps to <undefined>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/core.py", line 597, in _run_event_loop
    self._process_one_task_or_recover(task)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/core.py", line 610, in _process_one_task_or_recover
    return task.run(self)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/tasks.py", line 211, in run
    instance._process_one_event(self.event)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/core.py", line 706, in _process_one_event
    self._process_state_changed_event_into_session(event)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/core.py", line 812, in _process_state_changed_event_into_session
    if attributes_id := self._find_shared_attr_in_db(attr_hash, shared_attrs):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/recorder/core.py", line 725, in _find_shared_attr_in_db
    if attributes_id := self.event_session.execute(
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1712, in execute
    result = conn._execute_20(statement, params or {}, execution_options)
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/sql/lambdas.py", line 516, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
    ret = self._execute_context(
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
    self._handle_dbapi_exception(
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2047, in _handle_dbapi_exception
    util.raise_(exc_info[1], with_traceback=exc_info[2])
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
    self.dialect.do_execute(
  File "/srv/homeassistant/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
  File "/srv/homeassistant/lib/python3.9/site-packages/MySQLdb/cursors.py", line 199, in execute
    args = tuple(map(db.literal, args))
  File "/srv/homeassistant/lib/python3.9/site-packages/MySQLdb/connections.py", line 280, in literal
    s = self.string_literal(o.encode(self.encoding))
  File "/usr/local/lib/python3.9/encodings/cp1252.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode character '\u200b' in position 106: character maps to <undefined>
Dario82 commented 2 years ago

I have this problem too.

heyajohnny commented 2 years ago

I think it has something to do with your database encoding: This seems to be the same issue. Did the solution provided there fixes your issue?

heyajohnny commented 2 years ago

@pinthenet @Dario82 I've just released a new version where the unit of measurement is configurable through the configuration.yaml Please let me know if this has fixed your issue