Timezone Problem at Import InfluxDB data as sensor in Home Assistant

Hi, I am using InfluxDB as my history Database and want to get Some Informations as Sensor entity.

This is documented here: InfluxDB - Home Assistant

Problem is, that Home Assistant store the Data to InfluxDB in UTC. On InfluxDB Dashboard, I am using the following Command to get the correct values.

import "timezone"

option location = timezone.location(name: "Europe/Berlin")

This is working fine.

My example yaml Code:

- platform: influxdb
  host: !secret influxdb_host
  ssl: false
  port: !secret influxdb_port
  api_version: 2
  token: !secret influxdb_token
  organization: !secret influxdb_org
  bucket: !secret influxdb_bucket
  queries_flux:
    - imports:
        - timezone
      range_start: "today()"
      name: "Gasverbrauch heute von InfluxDB"
      unit_of_measurement: kWh
      unique_id: influxdb_gasverbrauch_heute
      query: >
        filter(fn: (r) => r["entity_id"] == "gas_zahlerstand_kwh")
        |> filter(fn: (r) => r["source"] == "HA")
        |> filter(fn: (r) => r["_field"] == "value")
        |> filter(fn: (r) => r["_measurement"] == "kWh")
        |> filter(fn: (r) => r["domain"] == "sensor")
        |> aggregateWindow(every: 1d, fn: spread, createEmpty: false)
        |> tail(n: 1, offset: 0)

But I can not add the option location parameter to my yaml query. How can I solve this problem?

1 Like

Would love to understand this as well!