MQTT handling if values are missing in payload

Hey there, i am still new with home assistant, but it is getting better. My current project is to read Mi Flora plant sensor value using tasmota esp32s. Unfortunatley auto discovery is not working with Mi Flora and tasmota, so i decided to create my own discovery messages for mqtt with a small python script. This is working so far really well. Unfortunately i have a small problem with battery values.

From tasmota i get a payload with different value and not every value is available in every message. With the battery value the problem is that if the battery payload is missign the value in HA is 0.

I think that is some kind of default behaviour of the mqtt inetgration. Now i am searchin a solution that simply let teh actual value the last value in the battery payload is empty. But - No idea

The value template to extract the battery value is:
value_template: '{{value_json.Battery}}'

Anyone an idea?

Found the solution. Change the value template to the following:

value_template: '{{value_json.Battery | isDefined}}'

So you will get no value at all or the value from the json but not 0 if there is no value