-- Port of zigbee-herdsman-converters linknlink.ts, upstream 5c69d62 (#13188). -- Sensor/action support only; parameter configuration awaits vendor protocol confirmation. local device = { meta = {optimistic = false}, model = 'eMotion Air', vendor = 'LinknLink', description = 'Battery-powered mmWave presence multi-sensor', fingerprint = {{model = 'eMotion Air', manufacturer = 'LinknLink'}}, exposes = {}, fromZigbee = {'temperature','humidity','occupancy','battery'}, toZigbee = {}, } for _, f in ipairs({{'temperature','°C'},{'humidity','%'},{'illuminance','lx'},{'battery','%'},{'linkquality','lqi'}}) do table.insert(device.exposes,{type='numeric',name=f[1],property=f[1],unit=f[2],access=f[1]=='linkquality' and 1 or 5}) end table.insert(device.exposes,{type='binary',name='occupancy',property='occupancy',access=5,value_on='true',value_off='false'}) table.insert(device.exposes,{type='enum',name='action',property='action',access=1,values={'single','double','triple','hold','release'}}) table.insert(device.fromZigbee,{cluster=0x0400,convert=function(msg) if not msg.is_attribute or (msg.cmd_or_attr_id~=1 and msg.cmd_or_attr_id~=0x0a) then return nil end local raw=(msg.attributes or {})[0] if raw==nil then return nil end return {illuminance=raw==0 and 0 or 10^((raw-1)/10000)} end}) table.insert(device.fromZigbee,{cluster=6,convert=function(msg) if msg.is_attribute then return nil end local action=({[2]='single',[1]='double',[0]='triple'})[msg.cmd_or_attr_id] return action and {action=action} or nil end}) table.insert(device.fromZigbee,{cluster=8,convert=function(msg) if msg.is_attribute then return nil end if msg.cmd_or_attr_id==3 then return {action='release'} end if msg.cmd_or_attr_id==1 and msg.payload[1]==0 then return {action='hold'} end end}) table.insert(device.fromZigbee,{cluster=0xfc01,convert=function(msg) if msg.is_attribute or msg.cmd_or_attr_id~=0 then return nil end local p=msg.payload or {} if #p<2 then return nil end local action=({'single','double','triple','hold'})[p[1]] if not action and #p>=2+p[2] then local chars={}; for i=3,2+p[2] do chars[#chars+1]=string.char(p[i]) end local s=table.concat(chars) if s=='single' or s=='double' or s=='triple' or s=='hold' or s=='release' then action=s end end return action and {action=action} or nil end}) return device