Unable to get gaz energy sensor on Energy dashboard

Hello,
I have a Zigbee sensor connected to the pulse output of my gaz meter (following french article Home Assistant: récupération Gazpar - AutoDomo).
I get a ‘gaz_counter’ entity that increments every 0.1 m3.
I have template configured as follow:

template:
  - sensor:
    - name: Gaz Energy
      unit_of_measurement: "m³ "
      state: "{{ states('input_number.gaz_counter') | int / 1000 | round(3) }}"
      device_class: gas
      state_class: total_increasing

When I add the ‘gaz_energy’ template to the Energy dashboard, I get an error saying that the sensor has an unexpected unit. I don’t really get why this is happening.

Do you have any idea ?

Regards

You can check this sensor in Developer tools states to see what does this provide.
Are you sure you don’t need to put in template.yaml for this sensor something like

- sensor:
  - name: "some name"
    unique_id: some_id
    everthing_else

Sorry I forgot to include the template and sensor lines. I edited the yaml code.

I don’t know if unique_id is necessary though as I don’t have it for my other templates

Here is what I see in my developer → state tab:

It is not necessary but open that entity and you will see.
It takes some time for energy dashboard to pick up state of that sensor. I think it should. Leave it for 2 hours. If it doesnt maybe you put wrong one in energy dashboard.

Is that extra space at the end your issue?

I’m not exactly sure how I can make sure to insert a m3 as UTF-8 character. For this, I copied the 3 from an online website (something like “³” U+00B3 Superscript Three Unicode Character) and when I pasted it got the space.
I tried removing it but I still get the same error message about the unit even after reboot of Home Assistant.

Go to Developer Tool – Statistics and look it up there to see if it gives any errors. You may have past data (either that space or something else) that’s got the wrong or different unit.

Developer tool - statics shows ‘no issue’ (my HA is in french). Data is being received and the energy valye keep increasing when my heating is on.

image