First, please read How to help us help you - or How to ask a good question, and especially the info about formatting code, and edit your post to improve the readability of your Yaml code.

What I understand from your post is that in your case the YF-B10 sensor has the following characteristics:

pulse rate characteristic F = 10 * Q - 4 with a flow range from 2 to 50 L/min at 5%

Here F is the pulse frequency in [pulses/sec] and Q is the flow rate in [L/min]

The 5% probably is the specified accuracy of the sensor.

So this formula calculates the pulse frequency or pulse rate F for a given flow rate Q.

But, similar to what I wrote in my previous post, we want to calculate the flow rate Q from the pulse frequency F, so we can rewrite the formula like this:

**F = ( 10 * Q ) - 4** with F in [pulses/sec] and Q in [L/min]

=> **F + 4 = 10 * Q**

=> **10 * Q = F + 4**

=> **Q = ( F + 4 ) / 10**

However, the ESPHome Pulse Counter Sensor defaults to [pulses/min], so we need to substitute F in [pulses/sec] with x in [pulses/min]

x in [pulses/min] = F * 60 in [pulses/sec] because there are 60 seconds in one minute.

**x = F * 60**

=> **F = x / 60**

**Q = ( F + 4 ) / 10**

=> **Q = ( ( x / 60 ) + 4 ) / 10**

=> **Q = ( x / 600 ) + 0.4**

So the filter should be:

```
filters:
- lambda: return ( ( x / 600 ) + 0.4 );
```

However, this linear function again does not go to zero when the pulse count is zero because when **x = 0** pulses/min then:

**Q = ( 0 / 600 ) + 0.4 = 0.4** L/min

So again like I wrote in my previous post, to correct for this, and knowing that the sensor flow range is only reliable between 2 and 50 L/min, we can modify the filter such that the flow rate Q goes to zero when the value comes below 2 L/min.

We already know that **x = F * 60** and that **F = ( 10 * Q ) - 4**, so:

**x = F * 60**

=> **x = ( ( 10 * Q ) - 4 ) * 60**

When Q = 2 L/min then:

**x = ( ( 10 * 2 ) - 4 ) * 60 = ( 20 - 4 ) * 60 = 16 * 60 = 960** pulses/min

So when x is smaller than 960 then we want Q to go to zero.

The modified filter then is:

```
filters:
- lambda: !lambda |-
if ( x < 960 ) return ( x / 480 );
return ( ( x / 600 ) + 0.4 );
```

The value 480 comes from 960 pulses/min divided by 2 L/min.

Lets now compare this new filter with you current filter.

The formula that you are currently using is:

Q = (x+4)/10/60 which in fact is:

**Q = ( x + 4 ) / 600**

It appears that this linear function is in fact very close to the new function we derived.

This plot shows both filters and how close the results are:

So in the end your current filter is not that far off at all at following the specified flow characteristics.

In fact the resulting value is 0.39 L/min too low for the complete range:

But if we zoom in to the area close to the minimum flow rate of 2 L/min it looks like this:

Here it is visible that the newly derived filter (in green) follows the correct values and goes to zero below 960 pulses/min or 2 L/min.

If your results are way more off then this means that your sensor does not follow its specifications and then it would be best to calibrate your sensor by measuring the true flow rate at several points, meaning measuring the resulting volume at several time intervals for several flow values, and deriving a better filter from these results.