core: Influxdb uncaught exception

The problem

My influxdb instance stopped working for a few weeks. Once I restart home assistant some datapoints are recorded and then the following exception is thrown:

Logger: root
Source: components/influxdb/__init__.py:430
First occurred: 8:58:05 AM (1 occurrences)
Last logged: 8:58:05 AM

Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 583, in run
    self.write_to_influxdb(json)
  File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 559, in write_to_influxdb
    self.influx.write(json)
  File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 430, in write_v1
    influx.write_points(json, time_precision=precision)
  File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 525, in write_points
    return self._write_points(points=points,
  File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 594, in _write_points
    self.write(
  File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 331, in write
    data = make_lines(data, precision).encode('utf-8')
  File "/usr/local/lib/python3.9/site-packages/influxdb/line_protocol.py", line 156, in make_lines
    for field_key, field_value in sorted(iteritems(point['fields'])):
TypeError: '<' not supported between instances of 'int' and 'str'`

Looks like one of the integrations (generic_hygrostat) is causing the TypeError (data is unavailable until certain components are loaded), however, I would expect influxdb integration to only fail to push that single datapoint instead of stop working altogether.

What version of Home Assistant Core has the issue?

core-2021.11.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

influxdb

Link to integration documentation on our website

https://home-assistant.io/integrations/influxdb

Example YAML snippet

influxdb:
  host: a0d7b954-influxdb
  database: home_assistant
  api_version: 1 
  max_retries: 100
  username: !secret indb_username
  password: !secret indb_password
  default_measurement: state
  tags_attributes: friendly_name

Anything in the logs that might be useful for us?

2021-12-07 08:58:03 WARNING (MainThread) [homeassistant.components.generic_hygrostat.humidifier] Unable to update from sensor: could not convert string to float: 'unknown'
2021-12-07 08:58:05 ERROR (influxdb) [root] Uncaught thread exception
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 583, in run
self.write_to_influxdb(json)
File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 559, in write_to_influxdb
self.influx.write(json)
File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 430, in write_v1
influx.write_points(json, time_precision=precision)
File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 525, in write_points
return self._write_points(points=points,
File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 594, in _write_points
self.write(
File "/usr/local/lib/python3.9/site-packages/influxdb/client.py", line 331, in write
data = make_lines(data, precision).encode('utf-8')
File "/usr/local/lib/python3.9/site-packages/influxdb/line_protocol.py", line 156, in make_lines
for field_key, field_value in sorted(iteritems(point['fields'])):
TypeError: '<' not supported between instances of 'int' and 'str'

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

It wasn’t the generic hydrostat integration. Looking at @jansemrad’s comment above I have realized that we had one custom integration in common - that being https://github.com/grinco/ote_rate/blob/master/README.md

Disabling ote_rate resolves the problem. I’ll try to find and fix the bug in the integration, however - I think this still should be caught and handled in influxdb, too.

No that shouldn’t be it, the integration won’t even pass through unknown. You can see it filters that state out here: https://github.com/home-assistant/core/blob/dev/homeassistant/components/influxdb/__init__.py#L220

Perhaps something to do with the attributes? What is the full state of the entity when it is not unknown?