Thanks @mfalkvidd for the welcome .
It did indeed the job, I somehow created a problem by making it again. (forgot to setup mqtt or something)...
But it's working now as I thought I wanted it.
At the moment I am trying to build a system that gets the last message from the sensor into the dashboard. So when the dashboard wants to refresh itself, he asks the latest sensor value from the MQTT broker. He gets the data and displays it then.
That was in my mind the most simplest solution for the first start.
So that the sensors can save their batteries and only the broker and gateway are hanging on power. When I need the data I request it. No need atm to save the data and query it from that.
Now my further thoughts were to use the retain function and a always active subscriber to log all the data getting into it to create statistics.
But I felt a bit that this is probably not the usual way, and I think atm that maybe I have misunderstood something about the concept. My first idea was also only to have the sensor values retained. But probably for that I need to change more(when that's the only way).
I also get the fact that when creating a bigger sensor network that storing all the data at the MQTT broker could become a problem . So now with two sensors running there is no problem, there's only a temp or hum value in it. No more so that's also not really I problem I think. But maybe if the MQTT broker has small storage it could be not smart.