Define a 'virtual' sensor?

Define an own sensor? Is this, what I want in my case?

I have a pressure sensor, which is read out every two seconds. The problem is, the values are not usable directly, as a pump might influence them. Hence, I measure in a loop and store always the last measurement value in a variable. Given a certain condition is met, I want to take that last value and present it to Home Assistant as the valid measurement.

One idea I have is to send a MQTT message when the condition is met. But I don’t know whether this is necessary.

Is it possible to define a ‘virtual sensor’, which’s value is updated every time the condition is met?

Thanks for pointing me in the right direction!

Is it a EspHome pressure sensor or ?

Nope. I use an adc input to read out the analog signal of the sensor. This works fine.

It’s just important to let HA read the measurement before the last one.

Ok, did you try a template sensor with a trigger ?

I think this could work!
Thanks!

I will report back…