Changing datasource of datapoint
I have two modbus serial data sources on my mangoes (internal and external usb serial adapter) and I changed the architecture of my modbus serial network a bit and would like to change the data source of a bunch of datapoints from one modbus serial datasource to another.
I have tried exporting the points i would like to move and find/replace the dataSourceXid and although the import tool says the points were saved the data source did not change.
also, it doesn't seem there is a way to change the datasource in the web interface, as there is no data source parameter for data points.
Is there a way to do this without loosing the points history/pointlinks/etc.?
phildunlap last edited by phildunlap
Edit: This post was incorrect
JoelHaggar last edited by
@JTFANA You can do this in the database. You would need to run some SQL Statements in the SQL Console. You'll want to restart Mango after you do this to get the chances loaded in. I would also recommend making a backup of your database first. You can do this on the system setting page under the H2 Database Settings section
Go to the SQL Console and run
select * from datasources
Find the ID of the source Data Source and the ID of the destination Data Source. Make sure they are both the same Data Source type.
Now you can run:
select * from datapoints where DataSourceID = 1
Where the DataSourceID is the ID of your source Data Source. Make sure these are the Data Points you want to move.
Now you can run this update statement to move the data points.
update datapoints set DataSourceID = (Destination Data Source ID) where DataSourceID = (source data source ID);
It would look like this for example:
update datapoints set DataSourceID = 2 where DataSourceID = 1;
Now go to the modules page and click the Restart this instance button to reboot Mango.
If you have problems with this you can easily restore your database from the backup you made so be sure to make that backup.
@phildunlap I first tried the JSON Import/Export method as that is what I am familiar with using to make similar changes, but for this it just wasn't sticking.
@JoelHaggar Thanks for the step by step instructions, it was extremely helpful as I don't have much experience with SQL queries. It worked like a charm, just had to add a device name filter to the update query as I didn't want to move all datapoints.