Grafana -> Influxdb query with tz and regex throws error despite correct syntax

I think something broken in recent updates, though I am a bit unsure which. I THINK it was HA Core.

I have grafana queries that look like this:

select mean(Watts)  from "Watts" WHERE "ct" !~ /Total/ AND $timeFilter GROUP BY time($__interval), "ct" fill(linear) tz('America/New_York')

InfluxDB returned error: error parsing query: found \, expected identifier, string, number, bool at line 1, char 126

This used to work. [**** Update see 2nd response below ****] To save you the trouble character 126 is between the ‘r’ and ‘i’ in America. And there’s no backslash in the query, nor in any of the data values.

If I take this into influxdb, removing $timeFilter and changing the interval as follows:

use HA; select mean(Watts)  from "Watts" WHERE "ct" !~ /Total/ GROUP BY time(1h), "ct" fill(linear) tz('America/New_York')

It works just fine, so it’s not influxdb that is unhappy. My GUESS is that some aspect of grafana passing the query to influxdb is breaking the format. I don’t know how to see the query passed, and influxdb has nothing interesting in the log, at least that I know how to find.

Interestingly if I remove the forward slash ('AmericaNew_York") I get the expected error that it is unable to find “AmericaNew_York” as a time zone, but the backslash error is gone. So I THINK this is related to an attempt to escape the forwardslash. If I attempt to escape the forward slash with an explicit backslash I still get the error finding the backslash.

Things I’ve done recently were updating core from 2024.9.3 to 2024.11.1 and grafana from 10.0.2 to 10.1.3. I rolled the latter back without change. I’m always afraid about rolling HA back so have not tried that. I am not 100% sure when it last worked, but almost certain those are the only things involved, which is why I am saying I think this is HA related not Grafana related, though emphasis on “think”.

Is this just me?

Did an HA update break escaping of strings somehow?

Linwood

PS. I put this in configuration as I do not know where to put “did the latest HA break this”, apologies if it’s the wrong place.

I decided I could just lose some time, so did a snapshot (hyperv), rolled back to 2024.9.3, and the problem persists.

I am sure this once worked. I am now less sure when it stopped working. I use it only for energy, and I was not using my energy data in a new house until I could get a lot of electrical work done. So while I am absolutely certain it once worked as it earlier this year, I am less sure if has worked in my new house since about August. I THINK it stopped in the last few weeks, but not sure.

But something updated in HA, InfluxDB or Grafana broke it, it’s the same query, and I think the format is proper.

I was wrong. I had made another change, and I figured out what it was. I renamed my sensors so that I could exclude them with a regex instead of explicit list. So the error is not a new bug. So

WHERE "ct" !~ /Total/ 

is a new format, and that is what is throwing things off, but ONLY if you also have the time zone with it’s forward slash.

Apparently something internally (not in influxdb but in grafana’s link to it) is being through by having the forward slash in the regex comparison AND in the tz().

On a related note, I think something must have changed in grafana (+/- influxdb) as I see that graphs now have a time zone specified there, and I did not actually need the time zone in the query. In fact it seems to be ignored. So I can just eliminate the tz().

But there is a parsing issue somewhere in the Grafana/InfluxDB/HomeAssistant combination.