[Solved] SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update Topic is solved

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

[Solved] SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by sebitop »

Version: 16997
Platform: raspberry pi
Description:

Hello,

I just updated to the latest Beta (V2025.2 build 16997).

Since the update, I’ve noticed that some LUA actions triggered by devicechanged on Selector Switches are no longer working.

To investigate, I created 3 new virtual selectors: TEST, TEST2 and TEST3.
I then wrote a minimalist script_device_test.lua to monitor them:

Code: Select all


-- Initialize the command array for Domoticz
commandArray = {}

-- Define the device name exactly as it appears in Domoticz
local target_device = 'TEST'
local target_device2 = 'TEST2'
local target_device3 = 'TEST3'

-- Check if the device that changed is our target device
if (devicechanged[target_device]) then
    
    -- Retrieve the status value (svalue) of the selector
    -- For selector switches, svalues usually return the level (0, 10, 20...)
    local sValue = otherdevices_svalues[target_device]
    
    -- Convert string value to a number for logic operations
    local level = tonumber(sValue)
    
    -- Log the results to the Domoticz log console for debugging
    print("------------------------------------------------------------")
    print("EVENT TRIGGERED: Device TEST has changed.")
    print("Detected Level (Number): " .. tostring(level))
    print("Raw Value (String): " .. tostring(sValue))
    print("------------------------------------------------------------")

end



if (devicechanged[target_device2]) then
    
    -- Retrieve the status value (svalue) of the selector
    -- For selector switches, svalues usually return the level (0, 10, 20...)
    local sValue = otherdevices_svalues[target_device2]
    
    -- Convert string value to a number for logic operations
    local level = tonumber(sValue)
    
    -- Log the results to the Domoticz log console for debugging
    print("------------------------------------------------------------")
    print("EVENT TRIGGERED: Device TEST2 has changed.")
    print("Detected Level (Number): " .. tostring(level))
    print("Raw Value (String): " .. tostring(sValue))
    print("------------------------------------------------------------")

end

if (devicechanged[target_device3]) then
    
    -- Retrieve the status value (svalue) of the selector
    -- For selector switches, svalues usually return the level (0, 10, 20...)
    local sValue = otherdevices_svalues[target_device3]
    
    -- Convert string value to a number for logic operations
    local level = tonumber(sValue)
    
    -- Log the results to the Domoticz log console for debugging
    print("------------------------------------------------------------")
    print("EVENT TRIGGERED: Device TEST3 has changed.")
    print("Detected Level (Number): " .. tostring(level))
    print("Raw Value (String): " .. tostring(sValue))
    print("------------------------------------------------------------")

end

-- Return the command array to Domoticz engine
return commandArray

if I click LEVEL1 on the 3 selectors, only one generates an action and domoticz ignores the 2 others

2026-01-01 19:55:41.944 VIRTUAL: Light/Switch (TEST)
2026-01-01 19:55:42.095 Status: LUA: ------------------------------------------------------------
2026-01-01 19:55:42.095 Status: LUA: EVENT TRIGGERED: Device TEST has changed.
2026-01-01 19:55:42.095 Status: LUA: Detected Level (Number): 10
2026-01-01 19:55:42.095 Status: LUA: Raw Value (String): 10
2026-01-01 19:55:42.095 Status: LUA: ------------------------------------------------------------
2026-01-01 19:55:43.013 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1710/TEST2/Set Level)
2026-01-01 19:55:43.021 VIRTUAL: Light/Switch (TEST2)
2026-01-01 19:55:43.844 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1711/TEST3/Set Level)
2026-01-01 19:55:43.849 VIRTUAL: Light/Switch (TEST3)
2026-01-01 19:55:47.712 Motherboard: General/Percentage (Memory Usage)


TEST works perfectly: the log displays the --- DEBUG and MATCH FOUND lines.

TEST2 and TEST3 are ignored: While the Domoticz general log shows the command being received (Status: User: sebastien initiated a switch command...), the LUA script does not trigger at all for these devices.

I have already tried restarting the service and recreating the devices on a new Dummy hardware, but the problem remains.

I have the same behavior on some other selectors that no longer react (while showing trigger in log)


maybe there were changes in events management in this beta?

open to test anything that could help resolving this bug

thanks for your help !
Kind regards
sebastien
Last edited by sebitop on Friday 02 January 2026 17:33, edited 3 times in total.
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: Issue with SELECTORS ignored since last beta update

Post by sebitop »

-tried to restart = nothing
-tried to rename TEST2 into TEST2_FIX = nothing
-tried to modify TEST2 into standard switch then modify it again to selector = nothing
-tried to delete and recreate TEST2 as a selector to change IDX = nothing

Bug is only on devicechanged where nothing happens on some selectors

if I use a script time to check the selector value it appears in the log

I don't know what to look after to better help

Kind regards
Sébastien
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by sebitop »

I tested to create a simple ON OFF switch and update my script_device_test.lua to detect any changes
now I have
TEST : switch selector
TEST2 : Switch selector
TEST3 : Switch selector
TEST4 : Switch selector
TEST5 : Switch

my script is as follow

Code: Select all

commandArray = {}

local d1 = 'TEST'
local d2 = 'TEST2'
local d3 = 'TEST3'
local d4 = 'TEST4'
local d5 = 'TEST5'

function checkDevice(name)
    if (devicechanged[name]) then
        local sValue = otherdevices_svalues[name] or "0"
        local level = tonumber(sValue) or 0
        print("------------------------------------------------------------")
        print("!!! EVENT DETECTED (Selector) !!!")
        print("Device Name: " .. name)
        print("New Level  : " .. tostring(level))
        print("------------------------------------------------------------")
    end
end

if (devicechanged[d5]) then
    print("------------------------------------------------------------")
    print("!!! EVENT DETECTED (Switch On/Off) !!!")
    print("Device Name: " .. d5)
    print("Status     : " .. tostring(devicechanged[d5]))
    print("------------------------------------------------------------")
end

checkDevice(d1)
checkDevice(d2)
checkDevice(d3)
checkDevice(d4)

return commandArrayy

only the first TEST Switch selector triggers the script (ie triggers devicechanged)
all the others switches are showing an event in the log but never activate the script

Code: Select all

2026-01-02 12:07:12.421 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1709/TEST/Set Level)
2026-01-02 12:07:12.435 VIRTUAL: Light/Switch (TEST)
2026-01-02 12:07:12.581 Status: LUA: ------------------------------------------------------------
2026-01-02 12:07:12.582 Status: LUA: !!! EVENT DETECTED BY DOMOTICZ !!!
2026-01-02 12:07:12.582 Status: LUA: Device Name: TEST
2026-01-02 12:07:12.582 Status: LUA: New Level : 10
2026-01-02 12:07:12.582 Status: LUA: ------------------------------------------------------------
2026-01-02 12:07:13.155 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1711/TEST3/Set Level)
2026-01-02 12:07:13.162 VIRTUAL: Light/Switch (TEST3)
2026-01-02 12:07:13.892 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1713/TEST2/Set Level)
2026-01-02 12:07:13.899 VIRTUAL: Light/Switch (TEST2)
2026-01-02 12:07:15.373 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1714/TEST4/Set Level)
2026-01-02 12:07:15.387 VIRTUAL: Light/Switch (TEST4)
2026-01-02 12:07:16.453 Status: User: sebastien (IP: 192.168.0.100) initiated a switch command (1715/TEST5/On)
2026-01-02 12:07:16.467 VIRTUAL: Light/Switch (TEST5)
I suspect something changed in the way domoticz manages the devicechange

if it helps...
thanks for your help as this has a massive impact on my setup with log of virtual switches triggering devicechanged.

cheers
sebastien
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by sebitop »

I tried to create a new script_device_ file using the same code inside and it works

it seems that all script_device_XXX. lua filenames created before the beta update are "burned" in the system

if I use script_device_test.lua = does not work
if I use script_device_testbis.lua = it works

I tied to search eveywhere but I don't know where domoticz logged these name files to decide avoiding them during a devicechanged.

so basically if I rename all the script_device_XXXX.lua into script_device_XXXX_v2.lua it works again
but something went wrong somewhere

if someone has an idea....
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by jvdz »

Pretty sure it has been the case for quite some time that a file based lua script will follow this logic:
script_device_name.lua where a check is made when the name matches the name of a device, the script will only fire when that specific device changes, else it will fire for each device event.
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by sebitop »

HI Jvdz

thanks for your answer and help

I remember this you are totally right and maybe this is why I don't see any action

will try to run another round of tests in that way and see if it works
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
sebitop
Posts: 78
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: SWITCH and SELECTORS ignored in DEVICECHANGED since last beta update

Post by sebitop »

Thanks again for the reminder that was exactly the issue!

I’ve had a script named script_device_clim_sam.lua running perfectly for months.
However, after upgrading Domoticz yesterday, I created a new text device also named 'Clim SAM' to track the air conditioning state.

Because the script and the device shared the same name (despite the underscore) , Domoticz was prioritizing that specific device and ignoring others!

I saw the same behavior with my test files; they were only triggering when the specific 'TEST' devices changed.
It’s all working perfectly now.

Thanks a million for that tip I’d completely forgotten!

Happy New Year to everyone!
domoticz on Raspberry Pi + RFXcom LAN moded
Blyss / DI.O / ESP / Arduino
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest