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

Adding Costs to Meter Consumption Data #8

Open
sebinity opened this issue Aug 2, 2023 · 4 comments · May be fixed by #16
Open

Adding Costs to Meter Consumption Data #8

sebinity opened this issue Aug 2, 2023 · 4 comments · May be fixed by #16
Assignees

Comments

@sebinity
Copy link

sebinity commented Aug 2, 2023

Hi, thanks for the great integration - it's been showing up-to-date kWh consumption data on my Energy Dashboard in HA extremely reliably so far. Which is why I've decided to go the next step of including consumption costs based on market prices and - after collecting some data - move to a contract with dynamic pricing.

The problem is that, after selecting the stromnetzgraz:energy_consumption_XXX to the dashboard, adding costs to it is greyed out and not selectable any more:
image

Trying to add a sensor tracking the EPEX spot price results in an error:
image

Cannot specify stromnetzgraz:energy_consumption_XXXXXXXX more than once for dictionary value @ data['energy_sources'][0]['flow_from']. Got [{'stat_energy_from': 'stromnetzgraz:energy_consumption_XXXXXXXX', 'stat_cost': 'stromnetzgraz:energy_consumption_XXXXXXXX', 'entity_energy_price': None, 'number_energy_price': None}, {'stat_energy_from': 'stromnetzgraz:energy_consumption_XXXXXXXX', 'stat_cost': None, 'entity_energy_price': 'sensor.epex_spot_at_net_price', 'number_energy_price': None}]

My assumption is that since the values in the consumption sensor are backfilled and not live, they don't want to work with a live data sensor. So my question now would be, is there a way around this?

@dreautall
Copy link
Owner

The only way I can imagine right now is that the integration does it itself - i.e. you (somehow) specify a sensor name in the integration settings (just like you do with your username/password) and it then calculates the price in a separate sensor while it backfills data.

I need to check if there is a proper way to pass a (foreign) sensor to the integration. I think I haven't seen an integration so far which does this...

@dreautall
Copy link
Owner

dreautall commented Mar 17, 2024

After digging into this a bit, it looks like I found a way to make it work - currently still WIP here: https://github.com/dreautall/ha-stromnetzgraz/tree/prices

It will rely on another sensor that provides continuous price data (expected in EUR/kWh). When the twice daily fetch runs that updates the statistic sensor, it will also update a second statistic sensor with the price data. This seems to work in HA from my first tests.

Obviously the integration will only backfill data as long as the price sensor existed in the past. I do not plan on adding an option to backfill with a static price or something like that.

Not sure yet what to do when the price sensor gets changed afterwards by the user. I guess the sensible thing is to keep all old price data. The other option would be to delete all prices and recalculate them with the new sensor...

I still need to flesh this out a bit (especially the "UI" part where you can put in the price sensor).

@dreautall dreautall self-assigned this Mar 17, 2024
@dreautall dreautall linked a pull request Mar 17, 2024 that will close this issue
3 tasks
@dreautall dreautall linked a pull request Mar 17, 2024 that will close this issue
3 tasks
@sebinity
Copy link
Author

Hey, thanks a lot for your effort on this! Unfortunately, I don't have a way test it. Stromnetz Graz doesn't let me access my meter data since mid of January - so no data for me to test this on...

@sebinity
Copy link
Author

Hey, so they have been able to get my smart meter back online so I can report back on the status and a few bits of feedback.

Overall, the price integration worked really well, it seems to calculate prices that are in the correct ballpark. I'll check exactly after this month when I get all data, but it seems to work. It updates well with each daily set of energy data. I'll stay on this branch until you'll merge it into main since I am quite happy with it. Thanks a lot for your work so far:
image

The only little bug I found was that, for some reason, the selectors for the Price sensor seemed to multiply on my Home Assistant instance with each reinstall:
image

A few bits and pieces of feedback that were a little confusing to me and may also be for new users that may be some additions for the documentation:

  • So I'm using the EPEX Spot integration, which only provies a price in ct/kWh. I honestly don't know how other integrations for live pricing do this, but maybe the integration could to the translation internally? I was unsure if a helper worked in the beginning, but it works fine, so a helper with this template would be a well addition to the documentation if you decide to release this:
    {{ (states('sensor.epex_spot_at_net_price') | float) / 100 }}
  • At the beginning, I was just trying to play with the already existing sensor in ct/kWh. So of course the price is 100x too high. I'll go and play with clearing this data from the SQL, but I feel like that also plays into your thought about what happens when the price sensor gets changed, maybe deleting old/wrong data (at least as an option) might be the worthwile strategy...
    image

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.

2 participants