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

enable use of multiple shelly plugs #346

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SoongJr
Copy link

@SoongJr SoongJr commented Feb 28, 2022

This also includes some changes to the dashboard (to make the names of the plugs show up on the board), migrating the time series panel while doing so.
Please note the change from singular to plural in the variable names, which might make it harder to merge changes for others, but it felt to me like the right thing to do.

@SoongJr
Copy link
Author

SoongJr commented Mar 1, 2022

I just noticed this is basically a duplicate of the abandoned PR #232 addressing feautre request #118 😂 (plus changes to the dashboard, but using a single set of credentials for all plugs)
Sorry @alexandruz, I was not trying to "steal" your code and contribute it as my own, I just hadn't seen your PR before (should have checked the closed PRs before spending all that effort implementing it on my own, but at least I learned a lot). I do think my dashboard changes at least do provide some improvements over #232, so I'll keep it open and see what happens.

@geerlingguy
Copy link
Owner

My goal is to test this with multiple plugs, but even testing with one plug and seeing success would be good enough for me.

@DanForever
Copy link

How does this affect existing data?

@SoongJr
Copy link
Author

SoongJr commented Mar 12, 2022

Good question that @DanForever!
tl;dr: the data is not lost, worst case the old data shows as a seperate plug to the ones you actually have with the name "shelly-plug".

Details:
Anytime you rename a "job" in prometheus it remembers the old data under the old job name, so it's not lost. Previously the name of the job for the shelly plugs was hardcoded to "shelly-plug", though you may have modified that ;) Nw you can configure the name of each plug in config.xml, so if you give one of your plugs the exact same name it previously had, the transition is seamless.
If you want to give every plug a good name, the old and new data will be treated as different plugs (one of which you don't get any new data for), so you'll have an extra gauge that's useless (always displaying the last recorded value I believe) and an extra line in the diagram with the old data, until it ages out of the retention period.

I haven't actually deliberately tested that, but I've renamed jobs a couple times and got the old data showing up like that, so I'm confident it will happen as I've described.
From what I've read, getting rid of old data is no easy feat, so I always deleted the whole database to get rid of old jobs 😅

@DanForever
Copy link

Good to know @SoongJr! :)
Do you know how easy it would be to update the old data so that it follows the new naming scheme?
I realise I have no idea how this data is stored under the hood, or how to access or backup that data...

Also, I wanted to mention it here as it's tangentially related, I bought myself one of the new Shelly Plus 1PM relays, but it has a new API vs the old ones, so I've updated @geerlingguy's script for polling the shelly, and created a pull request here: geerlingguy/shelly-plug-prometheus#6

@SoongJr
Copy link
Author

SoongJr commented Mar 13, 2022

I can tell you the data is kept in a prometheus database inside the prometheus docker container. I'm new to this stuff myself, so all I can advise is to google "prometheus change job name" or something. All data is linked to a job and you want to rename that from shelly-plug to whatever new name you are giving it. Hope it works out, please share your findings if you manage to do it ;)

@DanForever
Copy link

DanForever commented Jul 18, 2022

Any news on this one?

@DanForever
Copy link

Thought I'd poke my head in as we approach the anniversary of my last comment 😁. @geerlingguy I know you're a busy man, have you thought about appointing a moderator/collaborator/[insert-correct-nomclamenture-here] to act in your stead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants