Set status of a switch

Moderator: leecollings

Post Reply
mcwieger
Posts: 107
Joined: Tuesday 08 December 2015 9:59
Target OS: NAS (Synology & others)
Domoticz version: 2020.1
Location: Netherlands
Contact:

Set status of a switch

Post 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?
I moved to HomeAssistant. It was fun while it lasted!
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Set status of a switch

Post by jvdz »

Isn't this LUA script triggered indefinitely when you send an On each time the switch is switched on?

Jos
Last edited by jvdz on Saturday 27 February 2016 13:12, edited 2 times in total.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
mcwieger
Posts: 107
Joined: Tuesday 08 December 2015 9:59
Target OS: NAS (Synology & others)
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: Set status of a switch

Post 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
I moved to HomeAssistant. It was fun while it lasted!
mcwieger
Posts: 107
Joined: Tuesday 08 December 2015 9:59
Target OS: NAS (Synology & others)
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: Set status of a switch

Post 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?
I moved to HomeAssistant. It was fun while it lasted!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest