I have a situation that I hope you can help me with. I have a privately hosted server, to which I have access to the mysql database, etc. I have created a “master” user with all the required inputs, feeds, graphs, dashboard, etc, and enabled my server to be a multi-user one. So, before explaining how I am approaching this, let me first tell you the goal: I want to automatically create accounts for new users as the devices that sends their inputs come online, from where I want to “copy” all the inputs, feeds, graphs and dashboard from my pre-configured master user and make it available to the new user. I want to do this because I have close to 300 inputs, of which close to 250 of them stored in feeds, and to create that manually for 500 users, including graphs, dashboards from scratch, etc is not viable time wise.
So, herewith then a little background of how it works:
I have pre-written software on a raspberry pi that runs a little app at first startup to ask the user for their detail, after which it sends the .json command to the server to create the user. Based on this being a success, the write api key is copied from the response and automatically populated in the software. I do not mind having all the units post the same nodeID, as they will be posting to different accounts, so that’s not an issue.
Then I have a trigger on SQL that monitors the creation of new accounts, which then fires a bunch of SQL commands to copy the relevant data from my “master” user for each table, so effectively the new user ends up with all the inputs, feeds, graphs, dashboard, etc even before he logs in.
And now for the problem (why this does not work): When I created the input processors and feeds for my master user, they got assigned ID’s that increment as new processes, feeds, etc are added. So FeedID 30 might be populated by inputID 27, which is fair and well, but the moment I copy these values for a new user, it means that the new user would be trying to make use of feeds that does not belong to him. Besides that, the moment I copy a feed or input or any other data, a new ID is created for my new user, so the new user might end up having the feed with the same name as FeedID 2019 and inputID 183 for arguments sake, but it was copied with 1:30 as that’s what it was specified as on the master account.
So really this becomes a relational database issue, for which I hope there is a solution. That being said, I have very little Mysql knowledge, which may be exacerbating the problem too.
I have managed to create the inputs and the associated feeds using the .json Api commands, but ultimately that doesn’t help me at all, because the dashboard data is still referring to the feedid’s that belong to the master user, and that’s not just a column to update in the database.
So, after all of that, the real question is, is it possible to have a new user account setup automatically, including the dashboard, inputs, graphs, etc based on a master account (template)?
I really hope someone has tried this with a bit more success than me before…