27.01.2025, 10:19
This is your problem, Mosaic has a design issue and it is limited to few MBs of custom images. The limit is around 8-9MB but each time you use even same custom image it is still counted as new and added to the total. Run this script once, it will move all custom images to LM images and replace yours with url. The issue with such solution is that you will not see images from cloud. This will fix your project and if you still want to use custome images also in cloud then make the size as small as possible.
Code:
require('json')
require('encdec')
mosaickey = 'mosaic30:config:0'
config = storage.exec('get', mosaickey)
-- config = io.readfile('mosaic-backup.json')
config = json.pdecode(config)
icons = {}
relpath = '../../../../scada/resources/icons/'
abspath = '/www/scada/resources/icons/'
function fixicon(tbl)
local file = tbl.file
if type(file) ~= 'string' then
return
end
if file:sub(1, 10) ~= 'data:image' then
return true
end
local hash = encdec.md5(file)
if not icons[ hash ] then
local poss = file:find('/')
local pose = file:find(';')
local posd = file:find(',')
local ext = file:sub(poss + 1, pose - 1)
local filename = hash .. '.' .. ext
local data = encdec.base64dec(file:sub(posd + 1))
io.writefile(abspath .. filename, data)
icons[ hash ] = relpath .. filename
end
tbl.file = icons[ hash ]
return true
end
function fixstruct(tbl)
for key, val in pairs(tbl) do
if type(val) == 'table' then
if not fixicon(val) then
fixstruct(val)
end
end
end
end
fixstruct(config.floors)
fixstruct(config.imported_widgets)
config.custom_icons = icons
config = json.encode(config)
storage.exec('set', mosaickey, config)
------------------------------
Ctrl+F5
Ctrl+F5