HandyHat / ha-hildebrandglow-dcc

Home Assistant integration for UK SMETS (Smart) meters pulling data from the DCC via the Hildebrand Glow API
MIT License
231 stars 33 forks source link

Add multiple accounts #99

Closed ianfretwell closed 1 year ago

ianfretwell commented 2 years ago

I'd like to be able to add multiple accounts of this integration.

i.e. my own / parents / friend

in order to be able to compare usage between them.

Currently, if I simply add the integration again with another account everything seems to work perfectly. I can configure everything I need, rename entities, etc, setup the dashboard to do the comparisons. Perfect.

Right up to where I next restart HA:- at that point the devices from one instance are copied to the other AND all the entities from one instance appear to have been moved to the other instance at least that's how the GUI shows it - they are also then marked as 'Restored'. The screen grab here shows this (the two area's are essentially the two difference instances).

image

From that point forward only one instance is then working.

Am I missing something simple or is this expected behaviour - and if so, can it be fixed to allow multiple instances ?

Thanks!

ColinRobbins commented 2 years ago

The integration makes the assumption of a single account, so only stores one set of configuration parameters. Some am guessing when you restart all pick up the same, most recent, configuration.

ianfretwell commented 2 years ago

Thanks - is it feasible for it to be changed to allow multiple accounts so you think?

ColinRobbins commented 2 years ago

Yes, I think it’s feasible. It’s not a change I am personally motivated to make, and I have no way of testing it.

ianfretwell commented 2 years ago

No that's fine, entirely down to personal requirements.

For me, it makes more sense to be able to compare with others - as without that, what you might think is excessive usage turns out not to be and vice-versa.

Maybe some other users will chime in on this with their opinions.

balloob commented 2 years ago

The reason you see all your devices twice is because the sensor setup code adds data for all config entries instead of just the requested entry https://github.com/HandyHat/ha-hildebrandglow-dcc/blob/9d8bae14c718f5d2dd7f61e3f8c03d11206f393a/custom_components/hildebrandglow_dcc/sensor.py#L41

ianfretwell commented 2 years ago

Thanks...so it just needs a little code adjustment then ? - it's not something I know how to do myself but gives me hope this could be made to work!

HandyHat commented 1 year ago

This should now be possible in v1.0.0 but I am unable to personally test it. Please give it a go and let me know if this does not work @ianfretwell

With special thanks to the founder of Home Assistant himself for pointing out the issue.

ianfretwell commented 1 year ago

Many thanks. I'll let you know as soon as I get a chance.