Device_class water not supported in template sensor

Hello,

I am configuring water consumption using input.number helper ( in M3) and template sensor.

The templace sensor does not support the device_class water as there is an error " Value is not accepted. Valid values: “apparent power”, “aqi” , “battery” , …

below the template.yaml file

- sensor:
    - name: "water meter monthly"
      unit_of_measurement: "m³"
      unique_id: "water meter"
      device_class: water
      state_class: total_increasing
      state: "{{states('input_number.water_monthly') }}"

If i change the device_class to gas for example it works.

This is surprising as this is normally supported.
Anu advice please

which HA version are you on? This was introduced just recently

Ignore it, the VS Code extension has to be adjusted so it knows device_class: water is correct.

1 Like

So why does it work fine with me? I tried 2022.11.0 and now on 2022.11.3

It works fine for everybody, it is just the VSCode extension that isn’t updated yet, and throws an error about the device class because of this

The extension uses lists to check if the input is correct, and throws an error if the value is not correct. So the list used by the VSCode extension is incorrect, but if you save this, it would work fine in HA.

3 Likes

Thanks for all for your replies

@vingerha

The system was on 2022.11.2 at that time

@TheFes

What do you mean by “if you save this , it would work fine in HA” ?
How to update the VSCode extension ?

Thank you

I don’t know how to make that more clear. The error is because the VSCode extension is outdated, not because it isn’t accepted in Home Assistant.

I don’t think the extension is updated yet.

1 Like

The PR to add the device_class has already been created 23 days ago. But somebody has to merge it

3 Likes