I would like to measure how much gas is used when my underfloor heating is turned on. This is switched with a smart plug when my Tado has a heating request above 3% and switched off when the heating request is below 1%.
I asked ChatGPT how to do this and they came up with the following result:
*To set the start number of your P1 meter for monitoring gas consumption when the smart plug of your underfloor heating switches on and off, you can follow the steps below in Home Assistant:
Step 1: Ensure the correct setup
-
P1 meter: Ensure that your P1 meter is set up correctly and that your Home Assistant can read the data.
-
Smart Plug: Ensure that your smart plug of the underfloor heating is also properly integrated in Home Assistant.
Step 2: Set Input Numbers
Create two input numbers in your configuration.yaml
or via the Home Assistant UI to store the start and end number.
input_number:
start_getal:
name: Start vloerverwarming aan
min: 0
max: 100000
step: 1
eind_getal:
name: Stop vloerverwarming aan
min: 0
max: 100000
step: 1
Step 3: Set up automations
Create two automations: one to store the start number when the smart plug turns on, and one to store the end number when the smart plug turns off.
Automation for the start number
automation:
- alias: 'Gas vloerverwarming Start'
trigger:
platform: state
entity_id: switch.vloerverwarming
to: 'on'
action:
- service: input_number.set_value
target:
entity_id: input_number.start_getal
data:
value: "{{ states('sensor.gas_meter_gas') }}"
Automation for the end number
- alias: 'Gas vloerverwarming Stop'
trigger:
platform: state
entity_id: switch.vloerpompen
to: 'off'
action:
- service: input_number.set_value
target:
entity_id: input_number.eind_getal
data:
value: "{{ states('sensor.gas_meter_gas') }}"
Step 4: Calculate the consumption
You can add a template sensor to calculate consumption based on the stored start and end numbers.
template:
- sensor:
- name: "Gasverbruik Vloerverwarming"
unit_of_measurement: "m³"
state: >
{% set start = states('input_number.start_getal') | float %}
{% set end = states('input_number.eind_getal') | float %}
{% setverbruik_kwh = (end - start) %}
{% setverbruik_m3 = (verbruik_kwh * 3.6) / 31.65 %}
{{verbruik_m3 }}
Step 5: Testing and monitoring
-
Switch the underfloor heating on and off to check if the start and end numbers are stored correctly.
-
Check the value of the sensor “Gas Consumption Underfloor Heating” to see how much gas has been used.
Tips
- Make sure your Home Assistant is configured correctly and that all sensors are functioning correctly.
- Monitor the automations to make sure they are activated at the right time.
- Adjust the
max
value of the input numbers if you think you can use more than 10,000 kWh.
This should help you monitor the gas consumption of your underfloor heating!*
I have done everything as prescribed but in the automation I am running into a problem and I get an error message.
Does anyone have any idea whether the proposed method is the correct one and why I get the error message in the automations.
It has something to do with this line “Waarde”:
value: “{{ states(‘sensor.gas_meter_gas’) }}” because I can actually only enter numbers in data but those numbers have to be taken from my P1 meter “sensor.gas_meter_gas”.
Thanks.