InfluxDB Sensor Component

Does anyone know if you have to have the InfluxDB component set up to use the InfluxDB sensor?

I have data from another source going into an external (from Home Assistant) InfluxDB and want to extract it as a sensor, but don’t really want all of Home Assistant data in my InfluxDB as well.

I get the following error in the log:

2020-05-14 09:50:41 ERROR (MainThread) [homeassistant.setup] Error during setup of component influxdb
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/influxdb/__init__.py", line 123, in setup
    conf = config[DOMAIN]
KeyError: 'influxdb'

With the below sensor configuration:

platform: influxdb
host: 192.168.2.205
port: 8086
username: !secret influxdb_username
password: !secret influxdb_password
queries:
  - name: Energy Consumption
    unit_of_measurement: kWh
    measurement: '"autogen.rtlamr"'
    where: '"endpoint_id" = ''12345678'''
    database: rtlamr
    group_function: last
    field: consumption

And the query I am trying to imitate is (from Grafana):

SELECT last("consumption")  FROM "autogen"."rtlamr" WHERE ("endpoint_id" = '12345678') AND $timeFilter GROUP BY time($__interval) fill(null)

Your spacing is not correct. Everything under

platform: influxdb

needs to move up 2 spaces

That is not how the documentation shows the configuration.

# Example configuration.yaml entry
sensor:
  - platform: influxdb
    queries:
      - name: mean value of foo
        where: '"name" = ''foo'''
        measurement: '"°C"'

I also do not get any configuration errors when running “Check Configuration” with my current setup, but when I add the spaces, I get an error.

I have this in configuration.yaml :

influxdb:  
  host: 10.0.0.67
  port: 8086
  username: xxx
  password: xxx
  max_retries: 3

Probably your sensor does not work if the db is not set up in configuration.yaml