'Initialize the sensor.'

def __init__(self, hass, influx_conf, query):

    from influxdb import InfluxDBClient, exceptions
    self._name = query.get(CONF_NAME)
    self._unit_of_measurement = query.get(CONF_UNIT_OF_MEASUREMENT)
    value_template = query.get(CONF_VALUE_TEMPLATE)
    if (value_template is not None):
        self._value_template = value_template
        self._value_template.hass = hass
    else:
        self._value_template = None
    database = query.get(CONF_DB_NAME)
    self._state = None
    self._hass = hass
    where_clause = query.get(CONF_WHERE)
    where_clause.hass = hass
    influx = InfluxDBClient(host=influx_conf['host'], port=influx_conf['port'], username=influx_conf['username'], password=influx_conf['password'], database=database, ssl=influx_conf['ssl'], verify_ssl=influx_conf['verify_ssl'])
    try:
        influx.query('select    *    from    /.*/    LIMIT    1;')
        self.connected = True
        self.data = InfluxSensorData(influx, query.get(CONF_GROUP_FUNCTION), query.get(CONF_FIELD), query.get(CONF_MEASUREMENT_NAME), where_clause)
    except exceptions.InfluxDBClientError as exc:
        _LOGGER.error("Database    host    is    not    accessible    due    to    '%s',    please    check    your    entries    in    the    configuration    file    and    that    the    database    exists    and    is    READ/WRITE.", exc)
        self.connected = False
