Creating vacant message query and combining it with second query

Hi, I’m fairly new to grafana and since a couple of days I’m trying to cope with generating another aspect intoan existing measurement.

I’ve 30 inverters around and get a status measurements with a fixed meaning like status={0,1,2,3}. This is pretty simple and mostly an aspect of formatting the panel. I used a polystat panel with thresholds and colors and names, etc and build the query for it.
SELECT last("value") FROM "status" WHERE $timeFilter GROUP BY "inverter"

This worked in seconds. Every inverter has a status square with its name and the color green, yellow, red depending on the status transmitted.

But I’m struggling with the second aspect: Give me for example status=4 if the last measurement received is older than 30 minutes. The idea is to figure out which connection went dead and color it gray for example. I’ve tried different things regarding time duration like for example:

SELECT last(value) FROM status WHERE (time+30m)<now() GROUP BY "inverter"

but never got remotely right. What am I missing here? … when creating a list of grouped inverter tags which haven’t received updates for 30min…

I’ve tried build this aspect first and separately, but how can I later combine these two queries into a single value? Or is this not the right concept for the job?

Thank you