sbabcock23 / pytryfi

Apache License 2.0
31 stars 10 forks source link

Illegal mix of collations - database errors #18

Closed jakadia closed 2 years ago

jakadia commented 2 years ago

I am getting these logs in Home Assistant every time the sensors try to update. The sensors do show the current data accurately however, no data is updating in the History tab since I updated to Home Assistant 2022.7.

I am on the TriFi verion 0.0.14.1

Logger: homeassistant.components.recorder.core
Source: components/recorder/core.py:725
Integration: Recorder (documentation, issues)
First occurred: 8:47:33 AM (352 occurrences)
Last logged: 9:31:38 AM
Unhandled database error while processing task EventTask(event=<Event state_changed[L]: entity_id=sensor.rooster_monthly_steps, old_state=<state sensor.rooster_monthly_steps=282323; unit_of_measurement=steps, icon=mdi:map-marker-distance, friendly_name=Rooster🐔 Monthly Steps @ 2022-07-13T09:29:28.571356-05:00>, new_state=<state sensor.rooster_monthly_steps=282333; unit_of_measurement=steps, icon=mdi:map-marker-distance, friendly_name=Rooster🐔 Monthly Steps @ 2022-07-13T09:31:38.924549-05:00>>): (MySQLdb.OperationalError) (1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb3_general_ci,COERCIBLE) for operation '='") [SQL: SELECT state_attributes.attributes_id FROM state_attributes WHERE state_attributes.hash = %s AND state_attributes.shared_attrs = %s] [parameters: (1146600767, '{"unit_of_measurement":"steps","icon":"mdi:map-marker-distance","friendly_name":"Rooster🐔 Monthly Steps"}')] (Background on this error at: https://sqlalche.me/e/14/e3q8)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb3_general_ci,COERCIBLE) for operation '='")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 610, in _process_one_task_or_recover
    return task.run(self)
  File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 211, in run
    instance._process_one_event(self.event)
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 706, in _process_one_event
    self._process_state_changed_event_into_session(event)
  File "/usr/src/homeassistant/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 "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 725, in _find_shared_attr_in_db
    if attributes_id := self.event_session.execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1712, in execute
    result = conn._execute_20(statement, params or {}, execution_options)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/lambdas.py", line 516, in _execute_on_connection
    return connection._execute_clauseelement(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
    ret = self._execute_context(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1267, "Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb3_general_ci,COERCIBLE) for operation '='")
[SQL: SELECT state_attributes.attributes_id 
FROM state_attributes 
WHERE state_attributes.hash = %s AND state_attributes.shared_attrs = %s]
[parameters: (1116733253, '{"friendly_name":"Rooster🐔 - Collar Light"}')]
(Background on this error at: https://sqlalche.me/e/14/e3q8)
jakadia commented 2 years ago

moved to Hass-TryFi as it is related to Home Assistant