Trying to understand inconsistent data from InfluxDB sensor

Hi all,

I have multiple measures in InfluxDB coming from a Modbus device.
I also integrated those measures in HA as sensors.

- platform: influxdb
  api_version: 1
  host: influxdb
  port: 443
  ssl: true
  verify_ssl: true
  ssl_ca_cert: /ssl/ca_chain.pem
  username: "homeassistant"
  password: !secret influxdb_password
  queries:
    - name: PV_System_total_real_power
      unique_id: PV_System_total_real_power
      unit_of_measurement: 'W'
      database: "telegraf"
      measurement: "EKD_System_measurements"
      where: 'time > now() - 1h'
      group_function: "mean"
      field: "System_total_real_power"

The sensor works - but I am getting wrong readings in HA.

Using Chronograf to look at the measures in InfluxDB using this query

SELECT mean(“System_total_real_power”) AS “mean_System_total_real_power” FROM “telegraf”.“autogen”.“EKD_System_measurements” WHERE time > :dashboardTime: AND time < :upperDashboardTime: GROUP BY time(:interval:) FILL(null)

results in:

In HA I am getting this:

I guess there is some kind of misconfiguration in my sensor. Any suggestions to make the HA sensor match the data?

Ahh - as I was writing this Post I found that probably my sensor configuration was the issue.
I thought it might be possible that I get the mean based on a 1h time windows into HA and changed

      where: 'time > now() - 1h'

to

      where: 'time > now() - 1m'

This changed the game and I see the following graph in HA now:

That looks much more similar to the data from InfluxDB. But is still missing the spikes.

Probably I have to change the group function as well?