Update status without triggering

Moderator: leecollings

Post Reply
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Update status without triggering

Post by Melissen »

Hi,

I want to update some status of devices without triggering them.
I can get it to work, but only 1 switch at a time.

this is a part of the script:
-- Woonkamer alles
if (devicechanged['Woonkamer -alles']=='On') then
commandArray['UpdateDevice']='64|1|1'
commandArray['UpdateDevice']='65|1|1'
-- commandArray['UpdateDevice']='66|1|1'
-- commandArray['UpdateDevice']='70|1|1'
-- commandArray['UpdateDevice']='72|1|1'
end
if (devicechanged['Woonkamer -alles']=='Off') then
commandArray['UpdateDevice']='64|0|0'
-- commandArray['UpdateDevice']='65|0|0'
-- commandArray['UpdateDevice']='66|0|0'
-- commandArray['UpdateDevice']='70|0|0'
-- commandArray['UpdateDevice']='72|0|0'
end

In this case when switching ON, only nr65 is switched to ON, nr 64 stays OFF (66,70,72 are turned off, --)
When I switch OFF, nr 64 is switched OFF. (because 65,66,70,72 are turned off, --)
When I remove all -- in the commandlines, in both On or OFF only nr 72 switches.
So my conclusion is: only the last commandline is working.
How to get all commandlines working???

Thanks,
Hein
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
SweetPants

Re: Update status without triggering

Post by SweetPants »

Melissen wrote:So my conclusion is: only the last commandline is working.
That is right.
Did you check the wiki? https://www.domoticz.com/wiki/LUA_comma ... n_one_pass
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Re: Update status without triggering

Post by Melissen »

I saw this wiki-page.. but when i try to use this in the IF-THEN it doesn't work..
Even when I remove the commandArray = {} and return commandArray in the THEN-section, it doesn't work


Script I used:
commandArray = {}

-- Woonkamer alles
if (devicechanged['Woonkamer -alles']=='On') then
commandArray = {}
local function update(idx, value1, value2)
local cmd = string.format("%d|0|%.2f;%.2f", idx, value1, value2)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
update (64, 1, 1)
update (65, 1, 1)
update (66, 1, 1)
update (70, 1, 1)
update (72, 1, 1)
return commandArray
end

return commandArray


LUA is great, but the tutorials on Google aren't that great... Not a simple explanation, but only explaining a specific problem. So when you want to use a command in a different way, you get stuck very fast,
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Update status without triggering

Post by Westcott »

Hi Melissen,

Are you saying that if you update a device in this way (e.g. commandArray['UpdateDevice']='64|1|1') it doesn't trigger a devicechanged['MyDeviceIdx64'] ?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
SweetPants

Re: Update status without triggering

Post by SweetPants »

You can't have two "commandArray = {} and return commandArray" instructions.
This script works in my setup

Code: Select all

commandArray = {}

local function update(idx, value1, value2)
    local cmd = string.format("%d|0|%.2f;%.2f", idx, value1, value2)
    table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end

if (devicechanged['Lamp 3']=='On') then
 
	update (110, 11, 0)
	update (111, 22, 0)
	update (112, 33, 0)

end

return commandArray
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Re: Update status without triggering

Post by Melissen »

Hi Westcott. Indeed. When you use that command the switch will turn ON in your dashboard. But the device itself (lamp example) will not turn on.
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Update status without triggering

Post by Westcott »

Wow, thanks Melissen.
So an nValue of 1 (value1 in SweetPants' example) means 'On' ?
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Re: Update status without triggering

Post by Melissen »

Yeah... it works... After changing the string format to %d %d %d.....

Script is now:
commandArray = {}

local function update(idx, value1, value2)
local cmd = string.format("%d|%d|%d", idx, value1, value2)
table.insert (commandArray, { ['UpdateDevice'] = cmd } )
end
-- Woonkamer -alles
if (devicechanged['Woonkamer -alles']=='On') then
update(64,1,1)
update(65,1,1)
update(66,1,1)
update(70,1,1)
update(72,1,1)
end
if (devicechanged['Woonkamer -alles']=='Off') then
update(64,0,0)
update(65,0,0)
update(66,0,0)
update(70,0,0)
update(72,0,0)
end
return commandArray


Thanks everybody for helping me.... very happy with you !!!!

Hein.
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Re: Update status without triggering

Post by Melissen »

Hi Westcott.... yes for a switch you should use (idx,1,1)

See my script...
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
Melissen
Posts: 65
Joined: Wednesday 16 November 2016 9:39
Target OS: -
Domoticz version:
Contact:

Re: Update status without triggering

Post by Melissen »

Problem solved again...... and for all other switches is this a very easy script...
RFXcom433e ver1009,Raspberry Pi,Domoticz v3.5877

KaKu:16c remote,dimmer,wall-sockets,sunscreenswitch
Promax:wall sockets Elro:wall sockets Somfy:RFY screens
TFA:weather station Chinese temperature sensors, smoke detectors, power switches
Post Reply

Who is online

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