Selecting the last value of each sensor in a given timeframe

Hi,
im quiet new to fluxlang so im really struggling with creating queries.
I have the following situation:

  • there are N sensors on each floor in a house.
  • the sensors are sending values not constantly.
  • What i want to see as data is the latest value of each sensor that has sended data in i.e. the last 5mins (timeframe)
  • If a sensor has sent no data, it should not appear in the data list

i tried to define a query, but it gives me only one sensor.
Any suggestions?

from(bucket: "sensor.test")
  |> range(start: -5m)
  |> filter(fn: (r) => r["floor"] == "topfloor")
  |> filter(fn: (r) => r["_field"] == "p")
  |> last()

Have you checked this query in the GUI?
How often does each sensor send data?
What happens if you increase the range? Do you see more sensors?

sure i cheched the query in the GUI.
i made a small script that creates some mock data for the sensors within the given timeframe.
so data is definitively there.
but in the end i see only one datapoint in the table

function addData() {
	const writeApi = client.getWriteApi(org, bucket);
	console.log("write datapoint for");
	writeApi.useDefaultTags({ floor: "topfloor" });
	for (let index = randomNumber(0, 3); index < randomNumber(5, 8); index++) {
		writeApi.writePoint(
			new Point("sensor_" + index).floatField("p", randomNumber(-10, 20))
		);
	}
	writeApi
		.close()
		.then(() => {
			console.log("close write API");
		})
		.catch((e) => {
			console.error(e);
			console.log("\\nFinished ERROR");
		});
}

does anyone have any suggestions?