pipiche wrote: ↑Sunday 07 October 2018 15:51
In order to do some debuging, I need to find out a way to decode the Options column in the domoticz Database.
T2ZmfFNoYWtlfFdha2V1....
Now my question is can from a python script or some other script I can decode the Options['Zigate'] and Options['TypeName'] fields ?
In Lua (and dzVents) you can do this by using:
Code snippet
Code: Select all
-- Base string
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
-- decode function
function dec(data)
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end
local codedString = "T2ZmfFNoYWtlfFdha2V1cHxEcm9wfDkwwrB8MTgwwrB8UHVzaHxUYXB8Um90YXRpb24"
local codedString2= "eydSU1NJJzogMjQzLCAnWkRldmljZUlEJzoge30sICdUeXBlJzogJ0FxYXJhJywgJ1N0YXR1cyc6ICdpbkRCJywgJ1JJQSc6ICczJywgJ01hY0NhcGEnOiAnODAnLCAnQmF0dGVyeSc6IHt9LCAnSGVhcnRiZWF0JzogJzAnLCAnTW9kZWwnOiAnbHVtaS5zZW5zb3JfY3ViZS5hcWdsMDEnLCAnSUVFRSc6ICcwMDE1OGQwMDAyNzk4NGFlJywgJ1Byb2ZpbGVJRCc6IHt9LCAnRXAnOiB7JzAxJzogeycwMDAwJzoge30sICcwMDBjJzoge30sICcwMDEyJzoge319fX0"
dz.log(dec(codedString),dz.LOG_FORCE)
dz.log(dec(codeString2),dz.LOG_FORCE)
Result:
Code: Select all
2018-10-07 19:53:00.727 Status: dzVents: !Info: Off|Shake|Wakeup|Drop|90°|180°|Push|Tap|Rotation
2018-10-07 19:53:00.734 Status: dzVents: !Info: {'RSSI': 243, 'ZDeviceID': {}, 'Type': 'Aqara', 'Status': 'inDB', 'RIA': '3', 'MacCapa': '80', 'Battery': {}, 'Heartbeat': '0', 'Model': 'lumi.sensor_cube.aqgl01', 'IEEE': '00158d00027984ae', 'ProfileID': {}, 'Ep': {'01': {'0000': {}, '000c': {}, '0012': {}}}}
Just be clear.. Not invented by me

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki