Energy management using a binary_sensor

Hello,

I’m using a binary sensor to retrieve the cycles of my gasmeter via gpio. You can find the config of the corresponding sensors below.

I’ve tried to add the device_class: gas to my sensor, but this will be rejected by HA.
Is there any possibility to enable energy management for this type of sensor?
What do I need to add/change?

sensor 1:
  platform: template
  sensors:
    daily_gas_in_m3:
      unit_of_measurement: 'm³'
      #state_class: total_increasing
      #device_class: gas
      value_template: "{{ (states('sensor.daily_gas') | float / 100) }}"
utility_meter:
  daily_gas:
    source: counter.gascounter
    cycle: daily
binary_sensor:
  - platform: rpi_gpio
    invert_logic: true
    ports:
      18: GASZAEHLER

Best regards
Stefan

Use customise to add those attribute to your sensor.

I’ve added the attributes, and configured the Energy with this gas sensor. But no value appears after 2 days. Also, if I check again the sensor within the Customizer, I cannot see the settings. Will they remain persistent?

Regards
Stefan

Can you show your actual customize entry?

This is the current setting of my counter:

But I can’t select it as gas source inside the energy panel.

IIRC, you also need
unit_of_measurement: m³

This is given, see my 1st post. But mabye not at the correct sensor. I still can’t select it at the energy panel.

Well, it’s not in the sensor.daily_gas you showed above.
Why do you have that one and sensor.daily_gas_in_m3?

Whatever you do, the sensor must have unit_of_measurement, state_class and device_class set properly to be usable in the energy panel.

I checked again my configuration.yaml. I’ve added these attributes at different level of my gas counter sensor. It does not work, configuration check is failing. If I set it using the developer settings, it also not working because it will not be kept. Is there some better explanation how to modify this?
Or is there an integration that is using the GPIO pin gas counter?

I’m just a normal user and not developer, so I’m lost here and don’t know where to modify the sensor.

Thanks
Stefan