Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

today negative after import history #151

Closed
decommentator opened this issue Jul 27, 2023 · 18 comments · Fixed by #167
Closed

today negative after import history #151

decommentator opened this issue Jul 27, 2023 · 18 comments · Fixed by #167

Comments

@decommentator
Copy link

decommentator commented Jul 27, 2023

Imported the history with removing all current data in HA. Direct after import everything looks ok.
After some time today is all negative as if HA thinks I'm delevering instead of using.
(Did the same yesterday with the same result)

Using domoticz 2023.2

@Johanbos
Copy link
Owner

It could be that the incorrect sensorid was used during import. In my HA there are different sensors for consumption and production of electricity.

_20230728_065130

Investigating on sql level would be the best option to find out which sensor is doing what job.

@decommentator
Copy link
Author

the sensor is correct. Today everything is ok. History is ok. Except yesterday the time from import
Schermafbeelding 2023-07-28 100522
same for gaz. Only wrong @importtime

@Johanbos
Copy link
Owner

Ah next hint: use the value divider/multiplier. You might need to go from Wh to KWh etc.

@decommentator
Copy link
Author

it's strange as "today" is not in domoticz export
tried it with the different divider/multiplier options

@Erwin033
Copy link

At first, a big thank you for making this tool!
As decommentator, I have the same problem.

Would it be possible to delete al today's data?

@Johanbos
Copy link
Owner

Johanbos commented Aug 24, 2023

It is very easy to skip/delete parts of the import sql script. Leave out the last insert into value line. It should be at the end of all the values, recognizable by the date.

Within HA, if you know Sql well enough, you can alter any weird value or delete record manually. Be careful ofcourse and make sure you have your backup.

@enduring78
Copy link

@Johanbos How would I exclude some period of data?

Like with many users, there is some overlap between my Home Assistant instance being created and my Domoticz instance shutting down.

Therefore, what I think is happening is when changing the date in the queries to update the data, the sum will not match so there will be a huge negative value the day after the period I imported the records of.

Unfortunately I know only very basic SQL. I tried experimenting with deleting the record of that bad day, but I can't get it to work

@Johanbos
Copy link
Owner

Ah, in that case.. Yes, I should add the option to set an end date. I understand now that the incorrect sum could cause these issues.

As soon as have added this, I'll update this issue.

@enduring78
Copy link

Thank you! I will wait importing my data then to avoid the head age of removing the huge incorrect value ;)

Another thing I was thinking about is adding some kind of helpful text around the sum setting. I have done a bit of googling to the sum value, and I still don't fully understand it.

@Johanbos Johanbos mentioned this issue Aug 27, 2023
@Johanbos Johanbos reopened this Aug 27, 2023
@Johanbos
Copy link
Owner

Johanbos commented Aug 27, 2023

Could you give https://github.com/Johanbos/home-assistant-import/releases/tag/v0.2.1-ci.140 a try?

It incudes the end date option and I also tried to improve the options page, including a better description about the 'sum' / relative existing data.

Any feedback to improve is appreciated!

@enduring78
Copy link

enduring78 commented Aug 27, 2023

@Johanbos I tried the new version, but as soon as I try to load the Domoticz db, it crashes. This was working fine in the old version, so maybe a database parsing error?

I tried rebooting my machine and re-exporting the database, but it didn't work. I'm using Windows, it that matters.

@Johanbos
Copy link
Owner

Oops, I tested it with a pv export. I will test with domoticz soon.

@Johanbos
Copy link
Owner

Hmm, my Domoticz DB (from 2022, it's a bit old) is still working without any errors. Is there a error message you can share?

@enduring78
Copy link

I didn't get any error code, the program just quits.

I will try it again tonight on a clean VM with a new db export to rule out any other programs causing interference or something being wrong with the database.

@Johanbos
Copy link
Owner

Johanbos commented Aug 28, 2023

I've created #174 for the application crash issues. Multiple people are experiencing them.

@Johanbos
Copy link
Owner

Johanbos commented Sep 2, 2023

@enduring78
Copy link

Seems to be working like expected!

Will do some more testing later tonight, but on a test copy of my HA install all the history shows up!
The history shows up on the graph between 04:00 and 05:00 PM instead of midnight (what I expected), but this isn't a problem since the day view isn't useful anyway since we can't import the data hour-by-hour.

One small thing that can be improved is that the 'end date' isn't really clear. By trial and error I found out that this is the day the script will not touch, but some users (like myself) might assume this is the last that that will be imported.

@Johanbos
Copy link
Owner

Johanbos commented Sep 4, 2023

Updated end date parsing and description in https://github.com/Johanbos/home-assistant-import/releases/tag/v0.2.1-ci.159

@Johanbos Johanbos closed this as completed Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants