Skip to content

Instantly share code, notes, and snippets.

@zubir2k
Last active August 30, 2025 21:47
Show Gist options
  • Select an option

  • Save zubir2k/c64d407291b9b70cf9e2507110cf359b to your computer and use it in GitHub Desktop.

Select an option

Save zubir2k/c64d407291b9b70cf9e2507110cf359b to your computer and use it in GitHub Desktop.
Gas Consumption Based on Cooker Hood

🔥 Gas Consumption based on Cooker Hood

Requirement

  • Power monitoring switch (Wifi/Zigbee) installed to Cooker Hood
  • Assumption: Current above 40watt is considered running (adjust accordingly)

What to adjust

  • sensor.cooker_hood_power
  • float > 40 (change this to the current value that matched with cooker hood in running state)

Reference

https://www.elgas.com.au/elgas-knowledge-hub/residential-lpg/lpg-gas-unit-conversions

binary_sensor:
  - platform: template
    sensors:
      cooker_hood_running:
        friendly_name: "Cooker Hood Running"
        unique_id: cooker_hood_running
        value_template: >-
          {{ states('sensor.cooker_hood_power') | float > 40 }}

sensor:
  - platform: history_stats
    name: "Cooker Hood Running Time"
    entity_id: binary_sensor.cooker_hood_running
    unique_id: cooker_hood_running_time
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

utility_meter:
  tong_gas_meter:
    source: sensor.tong_gas_consumption_estimate
    name: "Tong Gas Meter"

template:
  - sensor:
      - name: "Tong Gas Consumption Estimate"
        unique_id: tong_gas_consumption_estimate
        icon: mdi:gas-burner
        device_class: gas
        state_class: total_increasing
        unit_of_measurement: ''
        state: >-
          {% set running_hours = states('sensor.cooker_hood_running_time') | float %}
          {% set consumption_rate_kg_per_hour = 0.3 %}
          {% set conversion_kg_to_m3 = 0.546 %}
          {% set consumption_kg = running_hours * consumption_rate_kg_per_hour %}
          {% set consumption_m3 = consumption_kg * conversion_kg_to_m3 %}
          {{ consumption_m3 | round(6) }}
        attributes:
          remaining: >-
            {% set initial_volume_m3 = 7.7532 %}
            {% set total_consumption_m3 = states('sensor.tong_gas_meter') | float %}
            {% set remaining_volume_m3 = initial_volume_m3 - total_consumption_m3 %}
            {{ remaining_volume_m3 | round(6) }}
          percentage: >
            {% set initial_volume_m3 = 7.7532 %}
            {% set total_consumption_m3 = states('sensor.tong_gas_meter') | float %}
            {% set remaining_volume_m3 = initial_volume_m3 - total_consumption_m3 %}
            {{ ((remaining_volume_m3 / initial_volume_m3) * 100) | round(2) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment