i am trying to make my own device adapter
like for current there is an adapter for 1 phase and also for 3 phase
there is already an adapter for voltage and now I want to make a new adapter for 3 phase voltage and one 3 phase power.
the documentation explains 'Create your own device adapter'
i have given the new adapter the following name 'voltage_3_phase_device'Create your own device adapter
If your device is not recognized by dzVents, you can still operate it using the generic device attributes and methods. It is much nicer, however, to have device specific attributes and methods. Existing recognized adapters are in /path/to/domoticz/dzVents/runtime/device-adapters. Copy an existing adapter and adapt it to your needs. You can turn debug logging on and inspect the file domoticzData.lua in the dzVents folder. There you will find the unique signature for your device type. Usually it is a combination of deviceType and deviceSubType, but you can use any of the device attributes in the matches function. The matches function checks if the device type is suitable for your adapter and the process function actually creates your specific attributes and methods. Also, if you call myDevice.dump() you will see all attributes and methods and the attribute _adapters shows you a list of applied adapters for that device. Finally, register your adapter in Adapters.lua. Please share your adapter when it is ready and working.
and placed in the folder: /path/to/domoticz/dzVents/runtime/device-adapters
and also Adapted Adapters point lua
Code: Select all
return {
baseType = 'device',
name = '3-phase Voltage device adapter',
matches = function(device, adapterManager)
local res = (device.deviceType == 'Voltage' and device.deviceSubType == 'CM113, Electrisave')
return res
end,
process = function(device, data, domoticz, utils, adapterManager)
device.voltage1 = tonumber(device.rawData[1])
device.voltage2 = tonumber(device.rawData[2])
device.voltage3 = tonumber(device.rawData[3])
function device.updateVoltage(voltage1, voltage2, voltage3)
return device.update(0, tostring(voltage1) .. ';' .. tostring(voltage2) .. ';' .. tostring(voltage3) )
end
end
}
what have I missed ? what am i not doing right?