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

Add last_reset attribute to daily cost sensors for correct Energy Dashboard costs #58

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

jeverley
Copy link
Contributor

This introduces logic to correctly populate the last_reset attribute of the monetary total sensors for gas and electicity.

Specifically this aims to address the issue raised in #57

@Blackduke77
Copy link

I have just updated my install with this file and am not seeing the attribute on my totals, I will leave it in place and see if they appear tomorrow!

@jeverley
Copy link
Contributor Author

jeverley commented Sep 10, 2024

I have just updated my install with this file and am not seeing the attribute on my totals, I will leave it in place and see if they appear tomorrow!

Are you able to see it in the Developer Tools > States section under the Attributes column?

Screenshot_20240910-185656~2.png

@Blackduke77
Copy link

Hi yes, if I look at states in developer tools, I see it as below, but I was looking at the entity and expecting to see it, which it isn't

image
image

@megakid megakid self-requested a review September 10, 2024 21:02
@megakid megakid merged commit 8740f4c into megakid:main Sep 10, 2024
@megakid
Copy link
Owner

megakid commented Sep 10, 2024

👍 thanks

@jeverley
Copy link
Contributor Author

jeverley commented Sep 11, 2024

@megakid I've just observed that gas resets at local time midnight (currently BST), whereas electricity resets using UTC midnight (at least for my supplier).

We might want to look at making this configurable if we see variations by supplier - @Blackduke77 if you have both, are you able to advise whether both your gas & electricity import today sensors reset at 00:00 local time? It looks like in your previous screenshot that your electricity resets at 00:00 (assuming your Home Assistant system time is Europe/London).

@Blackduke77
Copy link

image
image

Looks like you are onto something.

@jeverley
Copy link
Contributor Author

jeverley commented Sep 11, 2024

Thanks for checking @Blackduke77. How about in your history graphs for gas and electricity imported, at what time do you see them reporting 0?

Also do you know if you have a SMETS1 or SMETS2 meter?

With my meters I see gas resetting to 0 at 00:00 (BST) and electricity at 01:00 (BST).
We'll need to ensure that the last_reset times that the integration reports it's count

The current implemented logic uses local midnight for both gas and electricity, but I've a suspicion that we might need to make that configurable.

Screenshot_20240911-224737.png

Screenshot_20240911-224836.png

@Blackduke77
Copy link

they are current

image

@jeverley
Copy link
Contributor Author

Thanks for confirming, I think the current code should work for you then (as your meter is respecting DST).

I'll submit a PR tomorrow allowing users to configure an override - looks like it can be common with some suppliers: https://forums.moneysavingexpert.com/discussion/6452051/british-gas-electric-driver-ev-tariff-hours-gmt-vs-bst

@Blackduke77
Copy link

Happy to test, apart from basic functionality, is there anything else to test, do you want me to reset integration and reset it back up

@jeverley
Copy link
Contributor Author

jeverley commented Sep 13, 2024

Thanks @Blackduke77, it'd be good to test the following scenarios:

  • Update and make no config changes
    • Verify that last_reset populates for both electricity and gas using local midnight (23:00 UTC)
  • Choose Configure on your existing instance
    • Verify that the topic prefix and device ID match what you configured previously
    • Verify that the time zones default to the correct local time zone and that you can make and save a config change
    • Verify that the changes persist if you re-open the configure option
  • Set up a new instance of the integration

One thing I do notice is that the only way to make config changes take effect is to restart home assistant (this is also the case with the existing release).

I might have a look at making it reloadable similar to other integrations, though I'm off on holiday for the next week so it'll need to wait 🙂

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 this pull request may close these issues.

3 participants