I am living in a block house and therefore i do not have the possibility to change meters to smart meters. I would although like to keep an eye of the Electricity, Gas, Water consumption and my only way is to do it manually.
I have created a few input number helpers as such:
input_number.gas_meter
input_number.total_electiricity
input_number.cold_water_meter
input_number.hot_water_meter
As a next step i need to add these to the energy dashboard but since i cannot do it directly, i needed to created template sensors in the configuration file. Here is my code:
# Gas meter - In order for this to work create a number helper with name: Gas Meter
template:
- sensor:
- name: "gas_consumption"
unit_of_measurement: "mÂł"
state_class: 'total_increasing'
device_class: 'gas'
state: "{{ states('input_number.gas_meter') }}"
# Total Electricity Manual Meter - In order for this to work create a number helper with name: Total Electricity
- name: "electricity_total"
unit_of_measurment: "kWh"
state_class: 'total_increasing'
device_class: 'power'
state: "{{ states('input_number.total_electiricity') }}"
# Water Meters - In order for this to work create 2 number helpers with names: Cold Water Meter and Hot Water Meter
- name: "cold_water"
unit_of_measurment: "mÂł"
state_class: 'total_increasing'
device_class: 'water'
state: "{{ states('input_number.cold_water_meter') }}"
- name: "hot_water"
unit_of_measurment: "mÂł"
state_class: 'total_increasing'
device_class: 'water'
state: "{{ states('input_number.hot_water_meter') }}"
After restarting HA, i get a notification saying that the unit of measurement is not accepted for template. However, if i paste only the gas meter (the first one), it works and i am able to see it in the dashboard. There must be a syntax error and i have gone through the documentation but unfortunately i am not able to find an example of multiple template sensors in the configuration file.
Also, if someone is more experienced than me, are the device_class correct on every sensor above?
With the above code, home assistant passes the validation and restarts, however nor the electricity or water is appearing in the dashboard. I will try again…
I think i wasn’t clear… The sensors are not visible to be selected in the dashboard… You know, when you go to add a sensor to the grid, and water sections…
In order to avoid confusion as each one of you suggests changes to the code faster than i can reply, i will be providing actual code and error (if any). So far i have changed power to energy and i removed the quotes from the unit of measurement and the code is as follows:
# Gas meter - In order for this to work create a number helper with name: Gas Meter
template:
- sensor:
- name: "gas_consumption"
unit_of_measurement: mÂł
state_class: 'total_increasing'
device_class: 'gas'
state: "{{ (states('input_number.gas_meter')|float()) }}"
# Total Electricity Manual Meter - In order for this to work create a number helper with name: Total Electricity
- name: "electricity_total"
unit_of_measurment: kWh
state_class: 'total_increasing'
device_class: 'energy'
state: "{{ (states('input_number.total_electiricity')|float()) }}"
# Water Meters - In order for this to work create 2 number helpers with names: Cold Water Meter and Hot Water Meter
- name: "cold_water"
unit_of_measurment: mÂł
state_class: 'total_increasing'
device_class: 'water'
state: "{{ (states('input_number.cold_water_meter')|float()) }}"
- name: "hot_water"
unit_of_measurment: mÂł
state_class: 'total_increasing'
device_class: 'water'
state: "{{ (states('input_number.hot_water_meter')|float()) }}"