Page 1 of 1

aqara wall selector switch

Posted: Friday 30 August 2019 17:22
by tjabas
Hi!

im trying to get my aqara wall switch to control a lightbulb , but i dont understand even a bit of this dzVents programming stuff, since it is an selector switch it makes it difficult, im used to blocky, but this selector switch doesnt seem to work wit blocky, this is my script so far:

Code: Select all

return {
	on = {
		devices = {
			'Hallen_extra'
		}
	},
	execute = function(domoticz, switch)
	   if (switch.state == 'Right_klick') then 
	     
	     domoticz.devices('Hall_lampor').toggleSwitch()
		
	end
end
}
And its not working at all :(

What im trying to do is that when i press Right_klick on the aqara wallswitch it should turn on Hall_lampor

but its not working.

Re: aqara wall selector switch

Posted: Sunday 01 September 2019 23:02
by gerbenvanasselt
Here is an example,

for me it workes like this:

Code: Select all

return {

   on = { devices = { 'lumi.switch'}        -- Name of your button
    },           
   execute = function(dz, item, device)
        if item.state == '1 Click' then
            dz.devices('Woonkamer_Lamp2').toggleSwitch()    -- Name of your light
            dz.log(device.state, dz.LOG_INFO)
        end
   end
}

Re: aqara wall selector switch

Posted: Sunday 01 September 2019 23:48
by waaren
tjabas wrote: Friday 30 August 2019 17:22 im trying to get my aqara wall switch to control a lightbulb. What im trying to do is that when i press Right_klick on the aqara wallswitch it should turn on Hall_lampor
but its not working.
What might give you an idea on what is happening is to add some log statements.

Code: Select all

return {
	on = {
		devices = {
			'Hallen_extra'
		}
	},
	execute = function(domoticz, switch)
		 domoticz.log('state of ' .. switch.name .. ' is now ' .. switch.state, domoticz.LOG_INFO)		
		 domoticz.log('state of Hall_lampor  is ' .. domoticz.devices('Hall_lampor').state, domoticz.LOG_INFO)
	   	if (switch.state == 'Right_klick') then -- could this be a typo ?
     			domoticz.log('state of Hall_lampor  will be toggled', domoticz.LOG_INFO)
			domoticz.devices('Hall_lampor').toggleSwitch()
		else
			domoticz.log('no action needed for Hall_lampor', domoticz.LOG_INFO)
		end
	end
}