Float default null

How to get default null from float conversion? I read mqtt for sensor values and sometimes values are not set or empty and actually just set to ‘null’ string. I’m using jinja conversion to |float but don’t want |float(0) or any other number actually. Null means empty value and this is empty measurement. I can use IF checks before conversion but is there a better way of doing this? Like nan value in esphome?

You can’t. That’s why these filters with default values were added. Best you can do is to pick a sentinel value and handle that where necessary as the exception.

What kind of sensors are we talking about here?

Take a look at availability.

MQTT Sensor - Home Assistant (home-assistant.io)

yeah, but sentinel or not, it’s a value which will be influencing statistics etc. And the real value is ‘no value’ or ‘empty’, null, nan, unknown or whatever but definitely not 0 or any other number.
I have multiple remote esphome plant sensors writing to single mqtt topic like this

            payload: |-
              root["cabin_temperature"] = id(cabin_temp).state;
              root["cabin_humidity"] = id(cabin_hum).state;
              root["hhcc"] = "B00E";
              root["temperature"] = id(b00e_temp).state;
              root["moisture"] = id(b00e_mois).state;
              root["illuminance"] = id(b00e_ilum).state;
              root["conductivity"] = id(b00e_soil).state;

And then extracting single value needs to check for possible conversion problems. It’s so much code for a simple ‘do nothing’

    - name: "Plant B00E temperature"
      unique_id: plant_b00e_temparature
      state_topic: "adafruit.io/hhcc"
      state_class: measurement
      device_class: temperature
      unit_of_measurement: "°C"
      suggested_display_precision: 1
      device:
        identifiers: "5C:85:7E:B0:B0:0E"
        name: "Plant B00E"
        suggested_area: "RODos"
      value_template: >-
        {%if (value_json.hhcc == "B00E") and (value_json.temperature != 'null') %}
          {{ value_json.temperature|float|round(1) }}
        {%elif states("sensor.plant_b00e_temparature") != 'unknown' %}
          {{ states("sensor.plant_b00e_temparature")|float }}
        {%endif%}

offline sensors will not resolve value templates? Remember that after restart, mqtt sensors have unknown state, even if they are numeric. How come numeric sensor can have string value and it’s ok?