I use push buttons as wall switches in my house.
To turn the lights on/off in my house and need to create a toggleswitch in domoticz.
I first tried with blockly. Seemed to work at first. But when I keep pushing a button, the lights start to blink.

So I switched to lua scipts. But that had the same problem.
Then I saw that dzvents had a toggleswitch() command .
So I followed this tutorial and came up with this script.
Easy way to use a toggle switch.
return {
active = true,
on = {
devices = {
‘drukknop keuken’
}
},
execute = function(domoticz, drukknopkeuken)
domoticz.log(‘drukknopkeuken AAN’)
domoticz.log(drukknopkeuken.state)
if (drukknopkeuken.state == ‘On’) then
local lichtenkeuken = domoticz.devices(‘lichten keuken’)
lichtenkeuken.toggleSwitch()
end
end
}