Regrading the errors. You should use default for filters ( here |int) wherever you can. Esp. as they are thowing errors, if there is no value and you don’t use them (new for some releases, before it returned 0 or input value or …).
So have a look here
and use e.g.
states (‘sensor.water_mb_window_sill_battery’) | int(default=0)