Page 1 of 1

Disabling automatc addition of RFX devices

Posted: Friday 18 January 2019 23:57
by GJvdP
Hello dear devellopers,

I live in the center of a town. Everyday when I look in devices there are between 20 and 200 new devices in there that are not mine. Removing them is time consument and a pain to do. And they return at some point in time.
Is it possibble in a next relaese to disable this automatic recognition and only add RFX devices by learning them as is already possible on the switches page?

Also when deleting devices it would be nice if one could select a block of devices instead of having to select them one at a time. Or am I missing a trick?

Best regards,
GJ

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 9:37
by b_weijenberg
Setup - Settings - Hardware devices: disable Accept New Hardware Devices

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 10:10
by manutremo
I think that what the gjvdp is proposing is an option to disable automatic creation of new rfxcom devices. I would agree with the suggestion since I have the same problem.

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 10:16
by b_weijenberg
OK in other words:
Creation of new devices is disabled if you disable " Accept New Hardware Devices" in Setup - Settings - Hardware devices

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 10:28
by manutremo
Yes I know what that option does, there is no need to repeat. The point is that that option disables creation of ALL devices, while the request is an option to disable creation of ONLY rfxcom devices. Ideally, I guess an option to disable creation of devices BY type would be also welcome.

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 11:06
by waaren
GJvdP wrote: Friday 18 January 2019 23:57 Also when deleting devices it would be nice if one could select a block of devices instead of having to select them one at a time. Or am I missing a trick?
Goto devices tab
Click "Not used" button
Click invert selection
Invert selection
Invert selection
Invert selection.png (3.43 KiB) Viewed 1316 times
Click waste bucket
Waste bucket
Waste bucket
Waste bucket.png (2.7 KiB) Viewed 1316 times

Re: Disabling automatc addition of RFX devices

Posted: Saturday 19 January 2019 18:18
by waaren
GJvdP wrote: Friday 18 January 2019 23:57 Hello dear devellopers,

I live in the center of a town. Everyday when I look in devices there are between 20 and 200 new devices in there that are not mine. Removing them is time consument and a pain to do. And they return at some point in time.
Is it possibble in a next relaese to disable this automatic recognition and only add RFX devices by learning them as is already possible on the switches page?

Also when deleting devices it would be nice if one could select a block of devices instead of having to select them one at a time. Or am I missing a trick?

Best regards,
GJ
Until someone implemented this feature in domoticz, you can execute this dzVents script at regular intervals to remove the unused devices.

When not yet familiar with dzVents please start with reading Get started Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

-- deleteInactive

local httpResponses = "deleteInactive"

return {
    on      =   {
                    timer           =   { "at 16:24"    },                       -- Your preferred time or times
                    httpResponses   =   { httpResponses }
                },

    logging =   {
                    level           =   domoticz.LOG_DEBUG,
                    marker          =   httpResponses
                },

    execute = function(dz, item)
       local hardwareTypes2Delete =   
                                    { 
                                        "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",   -- All hardware types can be found in source file
                                        "RFLink Gateway USB",                             -- main/RFXNames.h
                                        "OpenZWave USB",
                                    } 
        local deleteAllUnused = false                                                     -- set true if you want to delete all unused devices
        local simulationOnly  = true                                                       -- set to false if you are ready to really delete unused devices
	
	
	local simulationString = ""
        if simulationOnly then 
           simulationString = "-- Simulation mode -- "
        end
        
        
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        local function getUnusedDevices()
            local  url = dz.settings['Domoticz url'] .. "/json.htm?type=devices&used=false" 
            dz.openURL({    url = url,
                            method = "GET",
                            callback = httpResponses })
        end
        
        local function deleteDevice(idx)
            if not simulationOnly then 
                dz.openURL( dz.settings['Domoticz url'] .. "/json.htm?type=deletedevice&idx=" .. idx)
            end
            logWrite(simulationString .. "deleting device id: "  .. idx)
        end
        
        local function processUnused(result)
            if result == nil then
                logWrite ("No unused devices found")
                return
            end
            for index in pairs(result) do
                if deleteAllUnused then 
                    logWrite(simulationString .. "Unused device " .. result[index].idx .. ", hardware Type: " .. result[index].HardwareType .. "; will be deleted.")
                    deleteDevice(result[index].idx)
                else
                    for i in ipairs(hardwareTypes2Delete) do
                        if result[index].HardwareType == hardwareTypes2Delete[i] then
                            logWrite(simulationString .. "Unused device " .. result[index].idx .. ", hardware Type: " .. result[index].HardwareType .. "; will be deleted.")
                            deleteDevice(result[index].idx)
                        end
                    end
                end
            end
        end
        
        -- Main
        if not item.isHTTPResponse then
            getUnusedDevices()
        elseif item.ok then                                      -- statusCode == 2xx
            processUnused(item.json.result)
        end
    end
}

Re: Disabling automatc addition of RFX devices

Posted: Saturday 26 January 2019 1:14
by GJvdP
Thanks all for the suggestions sofar.
On the subject of unwanted rfx devices, it is nice I can switch off automatic addition of such.
However, if I want to add devices I will run in to the same problem. If I am not fast enough new entries will be created that are not my devices. Deleting them is not a problem but my numbering goes out of wack at that moment.
And deleting unused devices also deletes entries of my own devices that are not used at the moment but might be needed at a later date.
So the original request still stands.

Re: Disabling automatc addition of RFX devices

Posted: Saturday 26 January 2019 9:11
by b_weijenberg
How many times do you add new devices?
Do you want to add new RFXtrx devices?
Which devices are created?

Maybe an option to disable the RFXtrx or the protocol in the RFXtrx for the specific unwanted devices during the time you like to add new devices.