Sensor mqtt tasmota ultrasonic

Hi to alla, i have an issue. Tasmota was inegrated in HA and i can see value for ultrasonic sensor. I configure tasmota for send mqtt info but when i activate the sensor in ha i recived “sensor not have a unique id” and this sensor is not aviable.
This my sensor

Now i need convert distance in percent, on tasmota i set rule for this, in ha can i creati manual sensor for them?


    - name: "EB1 Frequency"
      unique_id: EB1_Frequency
      state_topic: "tele/edpbox1/SENSOR"
      value_template: >-
          {% set x = value_json.EB1.Frequency|float(0) %}
          {% if x > 0 %}
            {{ x }}
          {% endif %}
      unit_of_measurement: "Hz"
      device_class: frequency
# /config/pkg/water.yaml
  - sensor:
    - name: T8 Water Level
      unique_id: t8_water_level
      state: >-
        {% set a = 0.40 %}
        {% set b = states('sensor.t8_ultrasonic')|float(None) %}
        {% if b != None %}
          {{ (a - b)|round(2) }}
        {% else %}
          {{ states('sensor.t8_water_level') }}
        {% endif %}
      state_class: measurement
      device_class: distance
      unit_of_measurement: "m"
      icon: "mdi:leak"


Just examples.

You may need to use filters too

Nice, but im not expert for this, this the misure

4cm = 100%
90 cm= 0%

You can help me for create the sensor for view the percent ?

It’s more easy do that with esphome


  - platform: ultrasonic
    trigger_pin: 5
    echo_pin: 4
    name: "${dev} Ultrasonic"
    update_interval: 2s
    accuracy_decimals: 2
    timeout: 1.0m
      - filter_out: nan
      - median:
          window_size: 5
          send_every: 5
          send_first_at: 5
      - sliding_window_moving_average:
          window_size: 5
          send_every: 5

Still need to add calibrate_linear

Ok, but i dont understand the mqtt i ha not able this sensor, i configure tasmota mqtt and send the percent but in ha i recived “sensor not aviable”

Check with mqtt explorer

i installed mqtt explorer and see this:
the mqtt sensor on HA is:
and on state i see this:

and tasmota console