Creating MQTT sensor in Home assistant

Hi All. Please if someone could point me in the right direction. I have connected a flow meter to a D1Mini using tasmota firmware. It works perfectly well and all data is brought into Home assistant with MQTT. I now however need to create a MQTT sensor using the values from tasmota.

This here is the code that I am using. I have put it in configuration.yaml undet MQTT

    unique_id: flow_meter_1
    state_topic: "tele/flow_meter_1/SENSOR"
    name: flow_meter_1
    value_template: "{{ ( value_json['COUNTER'].C1 | multiply(0.001648) | float ) | round(2) }}"
    unit_of_measurement: "l"

The MQTT sensor is created but the value shows at “Unknown”

What am i doung wrong?

post the json in "tele/flow_meter_1/SENSOR"

I appreciate your help but can you explain what you mean? I am a bit code challenged. I am not a coder at all

You have an MQTT topic named tele/flow_meter_1/SENSOR, post the value that’s in it at this moment.

It shows 11022 currently

Ok, so where did you get that template from then?

Are you using that device?

Not the exact device but similar. I still need to calculate the calibration

are you sure the multiplier is correct? Based on your topic response and what you’re saying, the template is completely different, which makes me doubt that the multiplier in the code that you provided is correct.

"{{ value | multiply(0.001648) }}"

Download mqtt explorer

Start it, connect to your mqtt broker, navigate to tele/flow_meter_1/SENSOR and show what is in the right pane under value

it is probably not correct but it should still give me a number in “L” correct? even though it might not be accurate until I have worked out the multiplier. Or am I understanding this wrong?

No, the template you posted is wildly incorrect. Your topic outputs a single number and you’re traversing in an object that doesn’t exist. Use the template I wrote previously.

Just fetching kids from school. Will be back in 20

Ok, so, when someone asks “what does your topic say” the answer would be what you just posted in that image.

Your original template is correct. You just have to wait for the value to update for it to change from unknown to a value.

Also, your topic does not match what you’ve posted. You used flow_meter_1 in your configuration but the topic in MQTT explorer shows Flow_Meter_1

Thank. I have changed the “F” to “f” and have blown into the sensor so that it would update but it still shows “Unknown”

Did you miss the M too?

:flushed:
I did. thanks so much for your time. It is working now. Rookie mistake