home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.18k stars 30.2k forks source link

Daily energy sensor only reports 23 hours of energy usage #107536

Open thomlov opened 9 months ago

thomlov commented 9 months ago

The problem

sensor _energy_consumption gives daily energy usage. Because it reports after the hour has happened, it always looses the energy usage hour 24 of every day.

sensor _compressor_energy_consumption gives the correct energy usage (because it reports continously), but for a multi split with several indoor units on one compressor it is not correct.

Instead of using a daily sensor that resets at midnight, maybe a total energy usage instead could solve this.

What version of Home Assistant Core has the issue?

core-2024.1.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

daikin

Link to integration documentation on our website

https://www.home-assistant.io/integrations/daikin

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 9 months ago

Hey there @fredrike, mind taking a look at this issue as it has been labeled with an integration (daikin) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `daikin` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign daikin` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


daikin documentation daikin source (message by IssueLinks)

bubonicbob commented 8 months ago

Both energy_consumption and compressor_energy_consumption are set to total_increasing which should allow HA to know that total energy usage is calculated every time the energy value increases. Basically it should ignore the reset to zero when it comes to overall energy calculation even though it shows you a chart where it resets to zero.

You can see that in the code here for example.

Maybe add a screenshot where things don't look right?

thomlov commented 8 months ago

Hello, thank you for taking the time to review this.

I have added some screenshots here:

Using the sensor in HA energy sensor reports less than daikin official app. The energy consumpion lost is equivalent of the energy usage of the hour between 23.00 and 00.00. See screenshot of two days, with compared values from corresponding days in daikin app

IMG_1721 IMG_1719 IMG_1718

IMG_1722

bubonicbob commented 8 months ago

It is intermittent? Are there days when it works fine and days when it does not?

When I looked at my own data, it seemed to show that it was picking up the right amount of energy on that same time.

Screenshot 2024-01-25 at 7 45 25 AM

But some days it is not picking it up.

Screenshot 2024-01-25 at 7 47 24 AM
bubonicbob commented 8 months ago

If I am reading the code correctly, the raw data comes from the last number of:

http://youraddress/aircon/get_week_power

Can you load that URL into your web browser and verify that this number is wrong compared to what your official Daikin app reports for your daily power usage?

bubonicbob commented 8 months ago

Oh I see the problem. The data is missing from the previous day.

This may be an issue with the sampling rate. The graph looks "bad" in that the previous day's total only shows 12.5 kWh whereas the get_week_power query shows a total of 12.6 kWh. The data for the current day is correct.

ret=OK,today_runtime=346,datas=20400/19500/14000/10700/8100/12600/4600

Here you can see that the graph never reaches the previous day's total as reported by get_week_power.

Screenshot 2024-01-25 at 8 11 20 AM

The current day's total matches what is returned by get_week_power.

Screenshot 2024-01-25 at 8 03 01 AM

I submitted an issue here since the bug probably needs to be fixed in the underlying pydaikin library.

thomlov commented 8 months ago

We must be sure to talk about the same thing.

The sensor "Compressor energy consumption" shows the energy usage for the outside compressor. This data is correctly found in get_week_power. However, this doesn't match the app - but that is something on daikin's side of things. Get_week_power reports "continuous" - as in update several times pr. hour. I can see you have som small errors here - I find the same - for the last week 1 day is reported 100w wrong, but the remaining 6 is correct. However, this error is so small that it doesn't really affect me that much.

The sensor "Energy consumption" however, is the one with my problem. The difference is that when you have one outdoor unit (compressor) and several indoor unit, this sensor reports the energy usage of just the one indoor unit. The sum of all sensors for indoor units, should then (in theory) match the compressor energy usage. "Energy consumption" only reports once per hour. It takes the data from "http://unit_ip/aircon/get_day_power_ex"

image

Adding up the numbers "prev_1day_heat" gives 63, that is 6,3 kwh. The daikin app reports 6,3 kwh. But HA reports 6,0 kwh, thus not reading the last hour of 0,3 kwh.

image

bubonicbob commented 8 months ago

Thanks for teaching me. I'm new to all this. :)

Looks like "compressor energy consumption" comes from today_total_energy_consumption which comes from datas in the get_week_power query. As you are pointing out, "energy consumption" comes from today_energy_consumption which comes from cur_day_heat + cur_day_cool and the get_day_power_ex query.

I wonder why the code reports energy usage from the heat data and not the sum of heat and cool. Wouldn't that be a bug? Oops I read the code wrong, it is the sum of heat and cool.

Unfortunately my Daikin unit doesn't seem to support returning any data from get_day_power_ex so that I always get zero kWh for my energy_consumption sensor entity.

ret=OK,curr_day_heat=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0,prev_1day_heat=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0,curr_day_cool=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0,prev_1day_cool=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0

In either case, once the data are collected from the query then they seem to be essentially processed in the same way. This would mean any lost data from the last time slice of the day is lost for the same reason and the fix should be the same for either entity.

bubonicbob commented 7 months ago

I resubmitted the issue since the pydaikin library has recently moved to github from bitbucket. The new issue is here.

Here is the reason why.

issue-triage-workflows[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

fredrike commented 4 months ago

@bubonicbob hello 🇳🇴 from 🇸🇪 .

Could you try to update your timezone on your Daikin unit as I think that is the problem.