A manual entry for electricity, gas and water consumption would be useful. in many cases you cannot create a smart solution with automatic collection of this data.
A field for the starting value and a field in which you can regularly enter the electricity, gas and water consumption in order to get a logging of the data.
I think you can do it with an Input Number - Home Assistant (described as total increasing as described on Benefit from long term statistics for any sensor and set with proper units).
Have you tested this kind of solution?
Hello, thanks for the reply.
No, unfortunately I donāt know how to implement this.
A starting value would also be important
There seems to be a soltuion: Utility Meter - take manual readings
Edit: However, when I tried to this, I got an error. Does not seem possible to use input_number as an input for a utility meter:
I got a bit further by defining a template sensor in configuration.yaml:
(First I created an āinput_numberā [stromablesen] helper to input the actual values)
input_number:
stromablesen:
initial: null
editable: true
min: 0
max: 100000
step: 1
mode: box
unit_of_measurement: kWh
icon: mdi:meter-electric
friendly_name: StromAblesen
Then I created a template sensor in Configuration.yaml:
template:
sensor:
name: "stromverbrauch"
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
state: "{{ states('input_number.stromablesen') }}"
I am now able to create the āUtility Meterā.
sensor:
strom:
state_class: total_increasing
source: sensor.stromverbrauch
status: collecting
last_period: 0
last_reset: 2022-11-04T00:33:23.138130+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter
friendly_name: Strom
But still no luck in using the final āstromā Utility Meter sensor on the Energy Dashboard. I am not able to select it as a energy source.
What am I doing wrong?
Edit:
I checked the definition of the metadata on the database. The unit of measure was recorded as āKWā even though I specified ākWhā when creating the sensors. After manually modifying the database records, I was able to add the āUtility Meterā to the Energy Dashboard.
SELECT * FROM `statistics_meta` WHERE statistic_id = "sensor.strom";
40 sensor.strom recorder kW 0 1 NULL
After changing the unit from ākWā to ākWhā I was able add the sensor āstromā to the energy Dashboard.
Hello,
so you made it Congratulation.
I want to try it too and hope you can help me.
I didnāt understand that with the database processing. am a beginner
My questions:
-
Can I bypass the problem beforehand? Without editing a database. As ?
-
Can I also enter meter readings from the past?
-
Can I enter an initial meter reading? Where?
Would be nice if you can help me.
Greetings Werner
So anyone made it to enter manual and historical data?
I found this, maybe it helps? It added a timestamp to a value, would be nice to enter older values.
Hello,
Thanks for the answer.
Unfortunately I donāt know where to paste the code mentioned there. I would like to have an input option. The date and meter reading should then be entered there.
Greeting Werner
Hello. Iām currently setting up manual tracking of my gas / water / power consumption. I want to share my findings with you, maybe some of this is helpful.
First I have created three input_number
helpers via the UI, namely input_number.gas
, input_number.power
and input_number.water
. Yeah, Iām not very good at naming things.
Then I have created three template sensors from these inputs:
- sensor:
- name: "Gas"
device_class: gas
unique_id: "current_gas"
unit_of_measurement: "mĀ³"
state: "{{ states('input_number.gas') }}"
state_class: total_increasing
- name: "Wasser"
device_class: water
unique_id: "current_water"
unit_of_measurement: "mĀ³"
state: "{{ states('input_number.water') }}"
state_class: total_increasing
- name: "Strom"
device_class: energy
unique_id: "current_power"
unit_of_measurement: "kWh"
state: "{{ states('input_number.power') }}"
state_class: total_increasing
Then I was able to use these sensors in my Energy Dashboard configuration:
I tried creating Utility Meter sensors before in UI and I could select them when setting up my energy dashboard but due to some misconfiguration (I assume) the consumption of the gas utility meter was not displayed. I then tried selecting the sensor directly and it looks like it is working now:
It looks like maybe there was some change in HA to the way that the energy dashboard has to be setup that I missed? But for me having input_number
together with template.sensor
seems to do the trick. I will report back here if something seems not right to me.
Now Iām left with the task to regularly collect my sensor data manually and Iām looking for a way to spread the difference of the value over the time since the last measurement taken. Because I will probably not take values every single day.
[EDIT]
Istās looking good so far. Iām currently taking readings every other or every third day. So rather infrequently. This doesnāt help me tracking my usage throughout the day, but at least with monthly to quartely accuracy.
Thatās an awesome guide, and I guess it could be marked as solution (if the Feature Requests forum allows that lol)
I even tried adding all the properties mentioned by @yonz2, but a couple of those donāt work at utility_meter:
(such as state_class
and status
, maybe more, I stopped trying lol)
Lastly, nowadays itās possible to set a Utility Meter directly in the Helpers panelā¦ but it doesnāt seem to like reading from input_number
It would be handy, so everything would be in the UI and we wouldnāt need to set a friendly name elsewhere (Iām looking at you, customize.yaml!!!)
EDIT: actually, for some odd reason (HA being HA), itās not being able to calculate properly the cost of those manual entries, even though it can calculate just fine if I add a deviceās consumption directly to that same section
That, together with the fact the graph for individual devices is sooo poor, kinda defeats all the time Iāve lost trying to make manual energy input to work
HA is completely lost with that issue, as there are not ācomplaintsā about some of the entities without cost, and complaints about some of the calculated ones (all of them using the same tariff entity):
Awesome and thanks for your guide!
Did you manage to find a way to add manual inputs ābackdatedā?
I would like to record them every two weeks or so but inform the system on which day the data refers to.
No, Iām sorry. I havenāt found an easy solution and have given up on that task. Would still be nice to get some sort of CSV import feature.
Would this custom integration by @klaj be a possibility? It imports historic statistics (like energy data) from a CSV.
Interesting, thanks for the link @StephenHā¦ I didnāt try yet but have the feeling it wonāt be sufficient for Energy. i.e. statistics will update but real energy consumption, counters, etc. will not
May give it a go on a test sensor and see how it works.
If anyone is interested, I posted some reasonably robust Python code to insert backdated state data into the states table. The source can be either a CSV file or a SQLite db ā with 2 columns (one for timestamp in UTC, other for data to be entered)
https://community.home-assistant.io/t/enter-delayed-aka-backdated-mqtt-data-asynchronously-based-on-attached-timestamp /750485/7?u=puterboy
Please see the following link for updated version that also adds the corresponding statistics to the statistics
and short_term_statistics
tables.