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

Bug in converter/history2db.js #395

Open
Alpini1980 opened this issue Feb 18, 2025 · 1 comment
Open

Bug in converter/history2db.js #395

Alpini1980 opened this issue Feb 18, 2025 · 1 comment

Comments

@Alpini1980
Copy link

Alpini1980 commented Feb 18, 2025

Hello,

I found a small bug in the converter/history2db.js which prevents some datapoints to be converted.

I converted a history.0 to a sql.0 instance (MSSQL-Server) with your script and most but not all datapoints were converted. So I searched for the reason why some datapoints were missing in SQL. The script said for example:

Ignore ID history.smartmeter.0.1-0~2_8_0__255.value.json: smartmeter.0.1-0~2_8_0__255.value

The datapoint-name in ioBroker and also SQL for this datapoint is

smartmeter.0.1-0:2_8_0__255.value but the filename is:
smartmeter.0.1-0~2_8_0__255.value.json

So the history-instance replaces ":" chars in filenames with "~" chars because ":" aren't allowed in filenames. But the converter script don't take these replaced chars into account.

As a quick and dirty workaround I changed line 198 from

const id = file.substring(8, file.length - 5);

to

const id = file.substring(8, file.length - 5).replace('~', ':');

which worked for me. But I am not sure if other illegal file name chars can cause the same problem so this shouldn't be a general solution.

Regards, Stefan

@Apollon77
Copy link
Contributor

I think this is a problem .....
The full logic is in

const safeId = id.replace(/[\u0000|*,;"'<>?:\/\\]/g, '~');
... so there is a lot more that gets replaced and the problem currently is that we can not reliably map back this because the pure JSON content does not contain any information on the real object ID ... so I have basically no real solution for that tbh

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

No branches or pull requests

2 participants