Auto create making duplicate devices

First place i saw this was in the openluup installation, where i got hundreds of duplicates over night.

Now i turned on auto create on my vera to add a switch, and the switch came up immediately with two devices, the second with a “1” on the end of the name.

Version 1.87

Had to reset my RFX completely, and did a reinstall with 1.96 using 433e with Type 1 FW.

This issue reoccurred, so I suspect that OpenLuup and Vera doesn’t handle the way RFX Plugin checks if the sensor is already there?

@tinman, How exactly does the plugin work in terms of checking if the sensorID is already in the system? Or can you point me to the code that handles it?

I noticed that the AltID and name is identical on all 3-15 instances the plugin made…

I found this in L_RFXtrx.lua:

------------------------------------------------------------------------------
-- Creation of new child devices
------------------------------------------------------------------------------
local autoCreate = (getVariable(lul_device, tabVars.VAR_AUTO_CREATE))
local tableNewDevices = {}
local tableConversions = {}
for _, command in ipairs(tableCmds)
	do
	altID = command.altid
	cmd = command.cmd
	if(cmd) then
		cmdDeviceType = cmd.deviceType
	else
		cmdDeviceType = nil
	end
	if ((altID and #altID > 0)
		and (cmdDeviceType)
		and (searchInTable2(tableNewDevices, 3, altID, 4, cmdDeviceType) == 0)
		and (searchInTable(tableConversions, 3, altID) == 0))
		then
		deviceIdNum = deviceIdNumByAltId[altID]
		-- Check if child exists but conversion is required
		local dev = nil
		if (cmd == tableCommandTypes.CMD_OPEN
			or cmd == tableCommandTypes.CMD_CLOSE
			or cmd == tableCommandTypes.CMD_STOP
			or cmd == tableCommandTypes.CMD_ON
			or cmd == tableCommandTypes.CMD_OFF
			or cmd == tableCommandTypes.CMD_DIM)
			then
			dev = findChild(THIS_DEVICE, altID, nil)
			if (dev)
				then
				if ((cmd == tableCommandTypes.CMD_OPEN
					or cmd == tableCommandTypes.CMD_CLOSE
					or cmd == tableCommandTypes.CMD_STOP)
					and (luup.devices[dev].device_type == tableDeviceTypes.LIGHT.deviceType
					or luup.devices[dev].device_type == tableDeviceTypes.DIMMER.deviceType))
					then
					table.insert(tableConversions, { luup.devices[dev].description,
						luup.devices[dev].room_num, altID, "COVER" })
				elseif (cmd == tableCommandTypes.CMD_DIM
					and luup.devices[dev].device_type == tableDeviceTypes.LIGHT.deviceType)
					then
					table.insert(tableConversions, { luup.devices[dev].description,
						luup.devices[dev].room_num, altID, "DIMMER" })
				end
			end
		end
		if ((dev == nil)
			and (autoCreate)
			and (findChild(THIS_DEVICE, altID, tableDeviceTypes[cmdDeviceType].deviceType) == nil)
			and (isDisabledDevice(tableDeviceTypes[cmdDeviceType].prefix..altID) == false))
			then
			table.insert(tableNewDevices, { nil, nil, altID, cmdDeviceType })
			debug("New device: altID: "..altID.." deviceType: "..cmdDeviceType)
		end
	end
end

@akbooer - It looks like its trying to search for the altID in existing sensors, do you see any reason for it not finding a previously made sensor?

Suddenly the managed devices list deleted itself, so i started from scratch again, this time with version 1.41. Now Auto Create works, and I can even have responsive motion sensors without using switch device files…

For info, this is the create device in 1.41:

	------------------------------------------------------------------------------
-- Creation of new child devices
------------------------------------------------------------------------------

local autoCreate = (getVariable(lul_device, tabVars.VAR_AUTO_CREATE) == "1")
local tableNewDevices = {}
local tableConversions = {}
for i, v in ipairs(tableCmds)
	do
	deviceId = v[1]
	cmd = v[2]
	cmdType = nil
	key = searchCommandsTable(cmd)
	if (key ~= nil)
		then
		cmdType = tableCommands[key][2]
	end
	if ((#deviceId > 0) and (deviceId ~= "parent")
		and (cmdType ~= nil)
		and (searchInTable2(tableNewDevices, 3, deviceId, 4, cmdType) == 0)
		and (searchInTable(tableConversions, 3, deviceId) == 0))
		then
		-- Check if child exists but conversion is required
		local dev = nil
		if (cmd == tableCommands.CMD_OPEN[1]
			or cmd == tableCommands.CMD_CLOSE[1]
			or cmd == tableCommands.CMD_STOP[1]
			or cmd == tableCommands.CMD_ON[1]
			or cmd == tableCommands.CMD_OFF[1]
			or cmd == tableCommands.CMD_DIM[1])
			then
			dev = findChild(THIS_DEVICE, deviceId, nil)
			if (dev ~= nil)
				then
				if ((cmd == tableCommands.CMD_OPEN[1]
					or cmd == tableCommands.CMD_CLOSE[1]
					or cmd == tableCommands.CMD_STOP[1])
					and (luup.devices[dev].device_type == tableDeviceTypes.LIGHT[1]
					or luup.devices[dev].device_type == tableDeviceTypes.DIMMER[1]))
					then
					table.insert(tableConversions, { luup.devices[dev].description,
						luup.devices[dev].room_num,
						deviceId,
					"COVER" })
				elseif (cmd == tableCommands.CMD_DIM[1]
					and luup.devices[dev].device_type == tableDeviceTypes.LIGHT[1])
					then
					table.insert(tableConversions, { luup.devices[dev].description,
						luup.devices[dev].room_num,
						deviceId,
					"DIMMER" })
				end
			end
		end
		if ((dev == nil)
			and (autoCreate == true)
			and (findChild(THIS_DEVICE, deviceId, tableDeviceTypes[cmdType][1]) == nil)
			and (isDisabledDevice(tableDeviceTypes[cmdType][4] .. deviceId) == false))
			then
			table.insert(tableNewDevices, { nil, nil, deviceId, cmdType })
			debug("New device: deviceId: " .. deviceId .. " cmdType: " .. cmdType)
		end
	end
end
if ((#tableNewDevices > 0) or (#tableConversions > 0))
	then
	updateManagedDevices(tableNewDevices, tableConversions, nil)
	return
end

What kind of switch are you adding via autocreate?

temperature sensors, with humidity, couple of motion sensors, and a few nexa switches… all coming in with a new device for each message they send…
Doesnt seem to matter what type it is, same behavior on all of them?

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules