Integrate water consumption in energy panel

it’s done !

configuraton.yaml

template:
 - sensor:
     -name:sensor.compteur_eau:
      unit_of_measurement: "m³"
      state_class: total_increasing
      device_class: water
      state: "{{states('compteur_eau') | multiply(0.001) }}"

There is an error message on the last line : Incorrect type. Expected “array”

you’ve got an indentation issue, look at the example

I’m sorry !

template:
  - sensor:
      - name: sensor.compteur_eau
        unit_of_measurement: m³
        device_class: water
        state_class: total_increasing
        state: "{{states('compteur_eau') | multiply(0.001) }}"

the device class “water” is not accepted and I have this same error message

Please put eau instead of sensor.compteur_eau as in the provided example.

template:
  - sensor:
      - name: eau
        unit_of_measurement: m³
        device_class: water
        state_class: total_increasing
        state: "{{states('compteur_eau') | multiply(0.001) }}"

the device class “water” is not accepted and I have this same error message : Value is not accepted …

the example has not been replicated exactly the same way. counter_eau is not appropriate. It must be something like counter.xxxxxx
Go to states tab, search for the counter that receives the water counts and click on the icon on the left to copy the id.
You may wish to send us a screenshot of it

ID : sensor.compteur_eau

This is where it not right.
You’ve got to have a counter not a sensor. You may create it with Helpers, and then from that a new template sensor is defined.

For gas, I did not create a counter with the helpers but a Utility meter with sensor.compteur_gaz as sensor input?

In the code, it is necessary at some point to refer to the sensor knx which contains the value?

yes indeed, which is, based on your screenshot:

{{states("sensor.compteur_eau")}}

I was wondering because you said : " It must be something like counter.xxxxxx"
I just installed a new instance of HA on a second virtual machine to avoid disrupting my production version.
I was able to display the electricity consumption without any problem but this is not the case for gas (the gas device-class exists).
knx.yaml

#Compteur gaz 
  - name: compteur_gaz2
    state_address: "9/7/1"
    type: "volume"

configuration.yaml

homeassistant:
  packages: !include_dir_named knx

template:
  - sensor:
    - template:
  - sensor:
    - name: gaz
      unit_of_measurement: "m³"
      state_class: total_increasing
      device_class: gas
      state: "{{states('compteur_gaz2') | multiply(0.001) }}"

How to simplify the last line because the value is already in m3?
HA-gaz

watch out. This is not correct:

state: "{{states('compteur_gaz2') | multiply(0.001) }}

The entity shall something like:

state: "{{states('sensor.compteur_gaz2') | multiply(0.001) }}

Look at dev/states to get the exact entity id

state: "{{ states('sensor.compteur_gaz2')  | multiply(0.001) }}"

You are missing the sensor platform prefix sensor. and the cast to float since states are strings. (Have not tested the above suggestion).

template:
  - sensor:
    - name: gaz2
      unit_of_measurement: "m³"
      state_class: total_increasing
      device_class: gas
      state: "{{states('sensor.compteur_gaz2') | multiply(0.001) }}"

HA-gaz2

Here is for electricity that works

look at your screenshot. The entity_id of this gas entity from knx is sensor.compteur_gaz without appended “2”.

knx.yaml
in the knx yaml it’s counter_gaz2

#Compteur gaz 
  - name: compteur_gaz2
    state_address: "9/7/1"
    type: "volume"

And we find counter_gas2 here
HA-gaz5

It seems that you do not understand from the very beginning that you have to refer to the entity id

This name key doesn’t mean anything anymore once the entity is created. So if you changed it at some point that wouldn’t be reflected in HA. It is not the entity_id.

friendly_name is also independent of entity_id and only used in frontend.

If I take it step by step

I put # in front of the gas lines of the knx-yaml and also for the whole gas template of the configuration.yaml
I restarted HA
I modified with gaz3

knx.yaml

#Compteur gaz 
  - name: compteur_gaz3
    state_address: "9/7/1"
    type: "volume"

configuration.yaml

template:
  - sensor:
    - name: gaz2
      unit_of_measurement: "m³"
      state_class: total_increasing
      device_class: gas
      state: "{{states('sensor.compteur_gaz3') | multiply(0.001) }}"

Entity ID is sensor.compteur_gaz3 . So far is everything ok?