Delete daily negative step measurements in InfluxDB

Hi there, influxDB noob here.

iPhones reset the daily step count by writing a negative value of the sum of all steps from the last 24h every day at midnight . This is expected.

How can I automatically delete this negative measurement, let’s say every night at 00:01?

Goal is to create history views of my step counts in Grafana grouped by day. Which is currently not possible due to this daily reset.

I found “Continuous Queries”, e.g.:

CREATE CONTINUOUS QUERY "cq_steps" ON "your_database"
BEGIN
  DELETE FROM "steps" WHERE "value" < 0
END

But I’m not able to apply this in InfluxDB UI in Home Assistant. All I get is a variety of errors, depending on how I alter the syntax.

Anyone out here willing to help a noob?

edit: alternativeley it would be even better to tell InfluxDB to ignore to record negative values before having them to delete afterwards. Is that possible?

Well… the noob found a solution to at least ditch the negative values in Grafana, knowing that they are still in InfluxDB, of course. That helps with the visualization.

AND ("value" > 0)

did the trick when added to the query.

However I’m still eager to learn how to ignore getting the negative values into the database in the first place / or delete them, if they cannot be ignored.

Any pointers?