State Timeline: how to show the last state up to the current time?

  • What Grafana version and what operating system are you using?
    Grafana v11.2.0 in a Docker container

  • What are you trying to achieve?
    Goal: state timeline of the on/off status of a certain switch, with the last state extrapolated to the current time (and not beyond)

  • How are you trying to achieve it?

My current InfluxDB query just gets the basic data:

from(bucket: “hubitat”)
|> range(start: -1d)
|> filter(fn: (r) => r[“_measurement”] == “switch”)
|> filter(fn: (r) => r[“deviceId”] == “${deviceIdVariable}”)
|> filter(fn: (r) => r[“_field”] == “value”)

When the time for the timeline is selected as “Today” , though, the last state is extrapolated all the way to the end of today, rather than stopping at the current time as expected:

If I choose “Disconnect values” with “Threshold > 1h” that somewhat works, but it seems it extends the last state beyond the current time. (shown in red below):

How do you extend the last state to the current time and not beyond?