Open Vitch612 opened 10 months ago
Chiming in to say I've noticed the same behaviour as well. I chalked this up to be an issue on Sonoff's end with them not setting the time correctly, even when we correct the time within the app by adjusting time zone in the settings. I ended up generating energy consumption data directly within Home Assistant with Riemann integrations as a workaround. The values are no an exact match to what the app reports, but it's close enough.
Hello @tonki486 thank you for your input. I am currently trying to avoid the path you have taken, possibly out of OCD behaviour and stubbornness, but there's also a good rationale to prefer avoiding chunks of an application running outside of its framework as this reduces service potential availability should any of the components stop working as well as it complicates maintenance and future evolutions. From what I have seen the issue is mainly that the time offset in the sonoff json file is defined as an integer. I am unfortunately not familiar enough with home assistant to easily point to the part that is generating the config file I have mentionned as well as the part that uses the information form this config file to determine the time offset. I am not sure how much AlexxIT has dug into the code nor if he'd have the time or will to check it out, but this seemed like a good place to ask a question about this issue as it makes more sense to have such a fix on SonoffLAN level rather then hope Sonoff's original integration authors to fix it.
I don't think this can be fixed from Hass side. Because the energy is collected in a cloud.
@AlexxIT Thank you for looking at the issue. It doesn't surprise me, that it is a eWeLink problem. Some things are just out of one's control. Appreciate the hard work that that you and the SonoffLAN group in support of this HACs add-on do!!
Hello, @AlexxIT and @lordwizzard, thank you both for your efforts looking into this. If the timestamp in ewelink is off by an hour this could be fixed on the sonoff plugin side. We can get the hard offset (which does not cater for daylight savings) from the file: {HASSMAINFOLDER}\config.storage\sonoff\{user@mail.com} from that json we extract the value of data-> {powermeterentryinthedevicesarray} -> params -> timeZone and then compare it to the actual current offset on the local system and correct the timestamps from within the plugin before inserting them into the db. I would gladly volunteer for this but python is not my strongsuit and HASS architecture is still murky to me.
The only issue that this integration level approach creates is that whenever the daylight saving change occurs there will either be a one hour gap or a one hour overlap. not sure what the best way to tackle this would be and this still seems better than having every day's average off by an hour.
The alternative to modifying the samples timestamps from the sonoff plugin that could eliminate the gap and overlap from that previous option would be to alter home assistant main code to account for this offset when handling energy samples however this feels to me like a much more complicated objective to achieve especially when those samples can have already been processed into statistical averages and counters. To illustrate my lack of comfort with the platform: I am still trying to figure out a way to manually alter the energy samples in the database and then reprocess the statistical averages. so far all my attempts led to same averages being recomputed and i can't figure out where the data used for those is coming from since my altered samples seem to be ignored.
Not sure if this should be posted here or on the original Sonoff integration. When using SonoffLAN 3.5.2 with an ewelink energy meter the reset time of the counter is only correct during half of the year when daylight saving time changes occur. At the time of setting up the power meter my utc offset was +3 and it is now +2 however the energy meter integration still operates on the assumption that it is +3.
Following is the device's configuration in .storage/sonoff/myemail@host.com which shows a timezone of +3.
I have tried changing the offset to +2 in this configuration file but it gets overriden on hass restart.
My question here would be how do change this timezone setting to, ideally a string defined timezone, or to a correct integer offset? I did not manage to figure out where the original configuration from which this sonoff configuration file is generated is stored.