Page 1 of 1

Set status of a switch

Posted: Friday 26 February 2016 21:01
by mcwieger
I have a device that needs two presses on the switch to get the correct status (on or off) displayed (see this topic http://domoticz.com/forum/viewtopic.php?f=6&t=4748). If you don't want to read through it: if the switch is Off and you press it, the switch turns on but the status remains Off. After pressing again, the status changes to On (and the switch stays on).

I'm trying to work around this issue, by adding another switch command (on or off) when the switch is pressed, using the followin lua script:

Code: Select all

commandArray = {}
 
if (devicechanged['Lamp 1'] == 'On') then
	commandArray[1]={['OpenURL']='192.168.2.201:8084/json.htm?type=command&param=switchlight&idx=24&switchcmd=On' }
end

return commandArray
And a similar script for the Off command.

The issue is: running this command triggers an additional On command (it switches on the switch a second time), but it doesn't trigger an additional status change of the switch (so it does the exact opposite of what I want).

The strange thing is: when I run the command in a browser, it actually does exactly what I want: it sets the correct status of the switch.

Any other ideas on how to "trick" a switch to think it's On or Off, or any insights in what I'm doing wrong?

Re: Set status of a switch

Posted: Friday 26 February 2016 21:09
by jvdz
Isn't this LUA script triggered indefinitely when you send an On each time the switch is switched on?

Jos

Re: Set status of a switch

Posted: Saturday 27 February 2016 12:37
by mcwieger
Hadn't thought about that, could be. But still, the switch status should be updated, but it's not.

Sent from my ASUS_Z00AD using Tapatalk

Re: Set status of a switch

Posted: Monday 29 February 2016 13:03
by mcwieger
Maybe to rephrase the question (or that results in three questions, actually):

1. is there a way to set the status of switch, without necessarily sending the command to operate the switch?
2. Is there a way to measure if a z-wave switch is on or off (e.g. with measuring the current)
3. In blockly there's a logic 'if device = on' whereas in LUA the logic is 'if devicechanged = on'). Is there a difference between the two? And if so, is it possible to use both of them in both languages?