Adding gas to energy dashboard (solved)

Same here, entity works fine, but not in energy. Add sensor in the json file, put is srill not presence i the setting

Hey, I have problem with gas sensor. I cannot select it in energy configuration. My sensor comes from esphome. This is esphome configuration:

sensor:
  - platform: template
    name: "iNode Gas"
    id: home_gas_m3
    unit_of_measurement: 'm³'
    accuracy_decimals: 2
    device_class: "gas"
    state_class: "measurement"

I see entity in home assistant with correct data. Only I cannot select it in energy configuration… Maybe someone had similar problem?

2 Likes

Hi,
I have slimme lezer for P1 port but unable to add it to energy dashboard. there is no device in the list not for gas not for energy.
Maybe im missing something?
Anyone idea?

I think state_class needs to be total_increasing for it to show up under energy configuration. I was able to get my fireplace gas consumption into HA with this setup, based on the time that switch.fireplace is on.

sensor:
  - platform: history_stats
    name: Fireplace runtime today
    entity_id: switch.fireplace
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

template:
  - sensor:
      - name: Fireplace gas
        unique_id: fireplace_gas
        device_class: gas
        unit_of_measurement: "m³"
        # Rated at 15,800 BTU/hour = 0.4476 m³/h
        state: "{{ (states('sensor.fireplace_runtime_today') | float * 0.4476) | round(2) }}"
        state_class: total_increasing

Just piling on here, my experience matches that of @stogs

I’m using rtl_433 to read my gas meter, which outputs in cubic feet (the dials on the front of the meter report CCF, hundreds of cubic feet, but the ERT radio output has two more digits). My MQTT sensor uses a value_template to convert this to cubic meters, and has a unit_of_measurement of m³.

Though the entity is set up correctly, I had to hand-edit it into the energy json file. It seems to be working OK but for 3 issues:

  • The numbers displayed are in cubic feet despite the legend being cubic meters
  • I’m not seeing cost accounting despite having set up the energy price
  • The Energy configuration panel still doesn’t see the gas sensor despite it working.

I suspect the first two issues are both related to confusion over units. For the third, maybe the devs are intentionally excluding setups that use imperial units because of these bugs. With luck we’ll see improvement in a future version.

You can check in ‘Developer tools/Statistics’ if there is something wrong with unit of measurement in your database.
It worked for me.

1 Like

@parkercat @Kyle @wonderslug I am using hertzg/rtl_433 docker as well, but I don’t see my gas meter in MQTT Explorer. I only see my 433 devices. How did you get this working?

Currently I am using allangood/rtlamr2mqtt docker for my gas meter and it works. But would love to have it so I could pull it all from one docker and not have to have two rtl-sdr devices.

I’m simply running rtl_433 with:

rtl_433 -R 149 -f  916000000 -M level -F  "mqtt://$MQTT_HOST:1883,retain=0,devices=rtl_433[/id]"

For the record I’m in eastern Massachusetts, USA with National Grid as my gas provider.

I chose 916 MHz as the frequency in my location with the best signal/noise ratio for my gas meter – the meters broadcast the same thing redundantly, hopping among frequencies between 910 and 920 MHz. In particular, 915 MHz is what’s used by Insteon so was not a good choice for me. If you need to listen to different frequencies you’ll either need multiple SDR dongles or frequency-hop over time, which you can find examples of in the docs.

You may need different values for the -R param depending on what protocol your meter sends. Run rtl_433 -R alone to see the list.

The -M level option adds signal strength etc. to the data being published.

Then, all the devices’ info is published via MQTT on topics rtl_433/<id>/*. You can see what’s being sent with mosquitto_sub -v -t \#. Evidently you can get JSON instead with events= instead of devices= but I had not found that tidbit when I set this up; see Basic rtl_433 operation | rtl_433

I’m doing something similar to what @parkercat mentioned.

I have another container running just for the 913MHz to always listen in to my gas meter with hertzg/rtl_433.

You can have it hop around frequencies, but I don’t do that since I have some single-event devices on the 433MHz band that I don’t want to miss when they send an event.

Can you share an example of your value_template for the mqtt sensor, I’m getting lost in trying to create one to convert my CCF gas meter to cubic meters.

To be fair, if your prefs select imperial units you’re better off using cubic feet not cubic meters. At least I think that’s why my energy panel says “m³” but the numbers are in cubic feet (it’s just cosmetic though). But here’s my MQTT sensor for cubic meters (my MQTT sensor publishes in cubic feet):

  - platform: mqtt
    name: "Gas Meter Direct"
    state_topic: "rtl_433/REDACTED/consumption_data"
    value_template: "{{ value | float(0) * 0.02831684659 }}"
    device_class: gas
    unit_of_measurement: "m³"
    state_class: total_increasing

I’m lost

I re-read this thread and can’t get it to work. My electricity consumption shows up but the gas doesn’t.

- platform: mqtt
  name: "value_json.Energy_Delivered"
  state_topic: "dsmr/p1/energy"
  unit_of_measurement: "kWh"
  value_template: "{{ value_json.Energy_Delivered }}"
  state_class: total_increasing
  device_class: energy
  

- platform: mqtt
  name: "value_json.Gas_Delivered"
  state_topic: "dsmr/p1/energy"
  unit_of_measurement: "m³"
  value_template: "{{ value_json.Gas_Delivered }}"
  state_class: total_increasing
  device_class: gas

When I watch the mqtt-stream I can see the raw values increasing…

{
    "Timestamp": "211122124805W",
    "Energy_Delivered": "50091.527",
    "Energy_Returned": "0.000",
    "Gas_Delivered": "14902.84",
    etc etc
....
}

ok, found It, sorry for spamming this topic, but at the first try I had kWh for the gas unit (copy-paste error) and thanks to Pablo I fixed it now: Adding gas to energy dashboard (solved) - #31 by pbadmin

The elektricity works, but not the gas meter. I have some strange value’s (see image below).
What can this be?

image

Hi!
i am try to get my gas sensor on energy dashboard …but does not appear
any ideias???

  • platform: template
    sensors:
    gas_consumption_m3_day:
    unit_of_measurement: ‘m³’
    device_class: gas
    value_template: >-
    {% set impulse_unit = 0.01 %}
    {% set impulse_count = states(‘sensor.contador_impulsos_gas_day’) %}
    {{ ‘unknown’ if impulse_count == ‘unknown’ else (impulse_count|int * impulse_unit|float) | round(2) }}

You’re missing a state_class: total_increasing or total depending on what data the meter provides

1 Like

With this topic I finally found out why my gas meter wasn’t showing up on my energy dashboard. I went in the developer tools, and clicked States and search for my gas meter entity. Indeed it did not have unit_of_measurement: m³. When I want to add it, it shows up briefly after hitting Set state but after a minute or so it disappears again. It looks like it doesn’t save somehow?

SO ANNOYING! Congratulations! That fixed it for me. I accidentally messed up my template the first time. I went back in and fixed the error but HA did not automatically update it in the database. I went in as you said and clicked “fix issue”. I also had to use F5(page refresh) in my energy dashboard but now I’m all good!

1 Like

When everything was correct here,it still wouldn’t show up. Then I changed the name of the template sensor, and only then the problem was fixed.
Then I found in Developer Tools that the sensor with the old name had many issues.

I cant add gas sensor to energy panel. in the sensor selection window, HA writes the following information:

"Choose a sensor that measures gas consumption in GJ, kWh, MJ, MWh, Wh units.

Note. It is not possible to add sensors that measure the volume of the gas and sensors that measure the amount of energy contained in the gas."

That is, HA does not allow adding a gas sensor with m3 measurement to the energy panel. When I change the unit_of_measurement from m3 to kWh, the sensor appears in the list, it does not want m3. there are no problems with statistics in the developer panel.