custom-components / sensor.unifigateway

High level health status of UniFi Security Gateway devices via UniFi Controller
131 stars 40 forks source link

Error updating the HA db with the component #19

Closed schettada closed 3 years ago

schettada commented 4 years ago

when the component is enabled, its throwing below error for recorder. looks like its not compatible with new structure of HA DB. it goes away when its disabled

Error saving events: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.DataError) (1406, "Data too long for column 'attributes' at row 1") [SQL: INSERT INTO states (domain, entity_id, state, attributes, event_id, last_changed, last_updated, created, old_state_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)] [parameters: ('sensor', 'sensor.unifi_gateway_alerts', '409', '{"1": {"_id": "5f56cedc6f5c27082df69750", "archived": false, "timestamp": 1599524571, "flow_id": 1925892575841743, "in_iface": "br0", "event_type": " ... (648304 characters truncated) ... Shell UCE. From: 182.18.208.118:54008, to: 10.0.1.3:80, protocol: TCP"}, "friendly_name": "UniFi Gateway Alerts", "icon": "mdi:information-outline"}', 75894, datetime.datetime(2020, 9, 8, 5, 56, 26, 477953, tzinfo=), datetime.datetime(2020, 9, 8, 5, 56, 26, 477953, tzinfo=), datetime.datetime(2020, 9, 8, 5, 56, 30, 840655, tzinfo=), None)] (Background on this error at: http://sqlalche.me/e/13/9h9h) (Background on this error at: http://sqlalche.me/e/13/7s2a)

jchasey commented 3 years ago

It looks like the data in the alert reported by Unifi has caused an issue when it was tried to be saved to the database. Clearing the alerts on the controller should remove the issue.