Page 2 of 2
Re: RE: Re: Updating the status of Domoticz switches without trigger
Posted: Tuesday 08 November 2016 10:33
by tequila
G3rard wrote:You can update the status of a switch without triggering any actions with commandArray['UpdateDevice'].
The following code lets you update a selector switch to level 10 without any triggering:
Code: Select all
commandArray['UpdateDevice'] = '263|10|10'
263 = idx
10 = level
Oh, cool! I am no longer in need of doing this but it is really good to know!
Thanks for sharing.
Re: Updating the status of Domoticz switches without triggering?
Posted: Saturday 12 November 2016 0:58
by nigels0
Just for a matter of record, here is how you change a switch through JSON:
Code: Select all
OFF
/json.htm?type=command¶m=udevice&idx=<IDX>&nvalue=0
ON
/json.htm?type=command¶m=udevice&idx=<IDX>&nvalue=1
Re: Updating the status of Domoticz switches without trigger
Posted: Monday 17 April 2017 10:34
by Andrex
G3rard wrote:You can update the status of a switch without triggering any actions with commandArray['UpdateDevice'].
The following code lets you update a selector switch to level 10 without any triggering:
Code: Select all
commandArray['UpdateDevice'] = '263|10|10'
263 = idx
10 = level
How can I "fire" the commandArray['UpdateDevice'] with MQTT? MQTT is the only messaging protocol I use between the actual devices (connected through RS232 with Node-Red that talk to and receive from DomoticZ via MQTT) and DomoticZ.
nigels0 wrote:Just for a matter of record, here is how you change a switch through JSON:
Code: Select all
OFF
/json.htm?type=command¶m=udevice&idx=<IDX>&nvalue=0
ON
/json.htm?type=command¶m=udevice&idx=<IDX>&nvalue=1
But that will trigger a domoticz/out MQTT message and the switches are listening to that topic to change their values, so is a no go option for me

since that will start a loop.
Re: Updating the status of Domoticz switches without triggering?
Posted: Wednesday 26 July 2017 18:34
by bebeno
Hi guys.
I would like to ask you one thing.
I try make my own wifi dimmer switch. I use my own lua script which is triggered when device change state.
BUT is possible to take the script to perform when the change is done through Domoticz. I mean, when I change state trought the web interface on the switch, but not when the change is done through the http command.
Thank you
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 27 July 2017 13:09
by sisaenkov
bebeno wrote:
BUT is possible to take the script to perform when the change is done through Domoticz. I mean, when I change state trought the web interface on the switch, but not when the change is done through the http command.
Your dimmer must have TCP server on it.
Check this topic:
http://domoticz.com/forum/viewtopic.php?f=38&t=4723
Re: Updating the status of Domoticz switches without triggering?
Posted: Friday 05 January 2018 5:36
by Wob76
Was there a solution for this, updating via JSON or MQTT?
I tried the previously mentioned method of adding a variable or fake svalue to my MQTT message, it works, but it also causes Domoticz to crash on a regular basis.
Really hanging for a solution so I can update switches and filter out the action coming back.
Thanks,
Wob
Re: Updating the status of Domoticz switches without triggering?
Posted: Tuesday 25 September 2018 8:15
by ben53252642
Surely someone knows how to do this?
I've need to update a devices battery and rssi WITHOUT actually triggering it on or off via MQTT.
Re: Updating the status of Domoticz switches without triggering?
Posted: Tuesday 25 September 2018 8:31
by ben53252642
Solved my problem using a uservariable in the Lua script, eg:
Code: Select all
-- Flood Sensor Kitchen
if (devicechanged['Flood Sensor Kitchen'] == 'On') then
message = "Domoticz#A flood has been detected in the kitchen."
commandArray['SendNotification'] = message
print(message)
commandArray['Variable:floodsensorkitchen']= "on"
elseif (devicechanged['Flood Sensor Kitchen'] == 'Off' and uservariables["floodsensorkitchen"] == "on") then
message = "Domoticz#Water is no longer detected in the kitchen."
commandArray['SendNotification'] = message
print(message)
commandArray['Variable:floodsensorkitchen']= "off"
end
Re: Updating the status of Domoticz switches without triggering?
Posted: Friday 12 April 2019 17:41
by nbleezi
Update switch status in Domoticz using DzVent, without executing the on/off command:
Code: Select all
execute = function(dz, item)
dz.devices(39).update(0,'Off')
dz.devices(39).update(1,'On')
end
,where
dz is the domoticz object,
39 is the device's IDX number.
Re: Updating the status of Domoticz switches without trigger
Posted: Sunday 04 August 2019 22:24
by Andrex
nayr wrote: ↑Sunday 24 January 2016 3:05
This is by design, when you press a button on the UI it makes that same JSON call.. This is an event, and it triggers them as such.
I can see the need for updating without an event, but this functionality does not exist currently.. perhaps an &silent feature can be added to it so it does not trigger an event.
Hi Nayr, any news on this?
Maybe we can use bountysource for helping with the code
Re: RE: Re: Updating the status of Domoticz switches without trigger
Posted: Tuesday 07 September 2021 12:16
by jurgend
tequila wrote: ↑Tuesday 08 November 2016 10:33
G3rard wrote:You can update the status of a switch without triggering any actions with commandArray['UpdateDevice'].
The following code lets you update a selector switch to level 10 without any triggering:
Code: Select all
commandArray['UpdateDevice'] = '263|10|10'
263 = idx
10 = level
Oh, cool! I am no longer in need of doing this but it is really good to know!
Thanks for sharing.
OMG this is a life saver, thx!
Re: Updating the status of Domoticz switches without triggering?
Posted: Tuesday 07 September 2021 14:47
by waltervl
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 12 January 2023 2:06
by HvdW
@waltervl
The Wiki doesn't give me the answer I'd like to read.
The Checkfirst is straightforward.
How is it implemented for blinds?
Usercase:
The blinds can be opened and closed from Domoticz as well as from the Shelly app.
If the blinds are closed using the Shelly app the blinds will still show open in Domoticz.
The Domoticz switch issues the command:
http://192.168.1.142/roller/0?go=open , not the Domoticz Json command
Can the the appearance of the blinds switch be toggled without firing the blinds using the update command?
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 12 January 2023 13:47
by waltervl
The dzVents .checkFirst will first check the status in Domoticz for the state of the blinds (open/close). when using blinds.open().checkFirst() If already open it will not send the open command.
But Domoticz has to know the status of the device.
and .toggle() I do not know if it works for blinds. But .checkfirst does not work with .toggle()
From the dZvents Doc
https://www.domoticz.com/wiki/DzVents:_ ... ng#Options
checkFirst(): Function. Checks if the current state of the device is different than the desired new state. If the target state is the same, no command is sent. If you do mySwitch.switchOn().checkFirst(), then no switch command is sent if the switch is already on. This command only works with switch-like devices. It is not available for toggle and dim commands, either.
Perhaps you need the .silent() option:
.silent(): Function. No follow-up events will be triggered: mySwitch.switchOff().silent().
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 12 January 2023 22:02
by HvdW
Well....
I've spent half a day spilling time, enjoying to program.
Little has come out of it.
Code: Select all
2023-01-12 19:00:00.347 Status: dzVents: Info: test: ------ Start internal script: test:, trigger: "every minute"
2023-01-12 19:00:00.365 Status: dzVents: Debug: test: Processing device-adapter for Screen 3: Switch device adapter
2023-01-12 19:00:00.365 Status: dzVents: Info: test: here we are at the start of the function
2023-01-12 19:00:00.365 Status: dzVents: Info: test: Closed
2023-01-12 19:00:00.365 Status: dzVents: Info: test: Screen 3 is Closed
2023-01-12 19:00:00.365 Status: dzVents: Info: test: Closed
2023-01-12 19:00:00.365 Status: dzVents: Info: test: ------ Finished test
2023-01-12 19:00:00.365 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2023-01-12 19:01:00.359 Status: dzVents: Info: test: ------ Start internal script: test:, trigger: "every minute"
2023-01-12 19:01:00.376 Status: dzVents: Debug: test: Processing device-adapter for Screen 3: Switch device adapter
2023-01-12 19:01:00.376 Status: dzVents: Info: test: here we are at the start of the function
2023-01-12 19:01:00.376 Status: dzVents: Info: test: unforeseen situation
2023-01-12 19:01:00.377 Status: dzVents: Info: test: ------ Finished test
The above log shows that one can influence the properties of a Blinds switch, one cannot change it from Open to Close or the other way round.
One can 'empty' the switch.

- open.jpg (15.26 KiB) Viewed 1169 times

- closed.jpg (14.11 KiB) Viewed 1169 times

- empty.jpg (14.2 KiB) Viewed 1169 times
Here is some code with which I tested.
Code: Select all
local SCREEN_3 = 'Screen 3' -- switch device
return {
active = true,
on = {
timer = { 'every minute' }, -- every minute for testing, 10 minutes when active
--devices = {'Screen 3'},
},
logging =
{
-- level: This is the log level you want for this script.
-- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
-- marker: A string that is prefixed before each log message.
level = domoticz.LOG_INFO and domoticz.LOG_DEBUG,
--level = domoticz.LOG_INFO,
marker = "test",
},
execute = function(dz, item)
local screen_state = dz.devices(SCREEN_3).state
dz.log('here we are at the start of the function', dz.LOG_INFO)
dz.log(screen_state, dz.LOG_INFO)
if screen_state == 'Closed' then
dz.log('Screen 3 is Closed', dz.LOG_INFO)
dz.log(screen_state, dz.LOG_INFO)
dz.devices(SCREEN_3).update()
elseif (screen_state == 'Open') then
dz.log('Screen 3 is Open', dz.LOG_INFO)
dz.log(screen_state, dz.LOG_INFO)
dz.devices(SCREEN_3).update()
elseif (screen_state ~= 'Closed') or (screen_state ~= 'Open') then
dz.log('unforeseen situation', dz.LOG_INFO)
dz.log(screen_state, dz.LOG_INFO)
end
end
}
You can test for yourself by creating a dummy switch which you can transform to a blinds switch.
It doesn't have to have a relationship with any existing device.
The positive side of this that I now can check the answer the Shelly device gives me and when that answer is not equal to the Domoticz state of the device one can make the switch aspect change to empty.
BTW
The silent() option triggers action
EDIT
After struggling many hours and publishing the above text I tried one last.
quietOn() and quietOff
That's it, nothing more, nothing less
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 12 January 2023 22:19
by waltervl
HvdW wrote: ↑Thursday 12 January 2023 22:02
EDIT
After struggling many hours and publishing the above text I tried one last.
quietOn() and quietOff
That's it, nothing more, nothing less
Well good it works now!
You also tried option .silent() ?
Re: Updating the status of Domoticz switches without triggering?
Posted: Thursday 12 January 2023 22:46
by HvdW
There's one more thing.
Code: Select all
local SCREEN_3 = 'Screen 3' -- switch device
return {
active = true,
on = {
timer = { 'every minute' }, -- every minute for testing, 10 minutes when active
--devices = {'Screen 3'},
},
logging =
{
-- level: This is the log level you want for this script.
-- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
-- marker: A string that is prefixed before each log message.
level = domoticz.LOG_INFO and domoticz.LOG_DEBUG,
--level = domoticz.LOG_INFO,
marker = "test",
},
execute = function(dz, item)
local screen_state = dz.devices(SCREEN_3).state
dz.log('Switch state before testing', dz.LOG_INFO)
dz.log(screen_state, dz.LOG_INFO)
if screen_state == 'Closed' then
dz.log('Before switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
dz.devices(SCREEN_3).quietOn() -- quietOn equals open
dz.log('After switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
elseif (screen_state == 'Open') then
dz.log('Before switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
dz.devices(SCREEN_3).quietOff() -- quietOn equals open
dz.log('After switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
elseif (screen_state ~= 'Closed') or (screen_state ~= 'Open') then
dz.log('unforeseen situation', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
end
end
}
Domoticz cannot handle the second call for the switch state.
Code: Select all
if screen_state == 'Closed' then
dz.log('Before switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
dz.devices(SCREEN_3).quietOn() -- quietOn equals open
dz.log('After switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
The second
Code: Select all
dz.log('After switching state', dz.LOG_INFO)
dz.log(dz.devices(SCREEN_3).state, dz.LOG_INFO)
gives the same output as the first whilst the view of the switch Open or Close actually has changed (has been toggled)
The log:
Code: Select all
2023-01-12 22:47:00.548 Status: dzVents: Info: test: ------ Start internal script: test:, trigger: "every minute"
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: Processing device-adapter for Screen 3: Switch device adapter
2023-01-12 22:47:00.565 Status: dzVents: Info: test: Switch state before testing
2023-01-12 22:47:00.565 Status: dzVents: Info: test: Open
2023-01-12 22:47:00.565 Status: dzVents: Info: test: Before switching state
2023-01-12 22:47:00.565 Status: dzVents: Info: test: Open
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: OpenURL: url = http://127.0.0.1:8383/json.htm?type=command¶m=udevice&nvalue=0&svalue=0&idx=33
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: OpenURL: method = GET
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: OpenURL: post data = nil
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: OpenURL: headers = nil
2023-01-12 22:47:00.565 Status: dzVents: Debug: test: OpenURL: callback = nil
2023-01-12 22:47:00.565 Status: dzVents: Info: test: After switching state
2023-01-12 22:47:00.565 Status: dzVents: Info: test: Open
2023-01-12 22:47:00.565 Status: dzVents: Info: test: ------ Finished test
Re: Updating the status of Domoticz switches without triggering?
Posted: Friday 13 January 2023 12:11
by HvdW
waltervl wrote: ↑Thursday 12 January 2023 22:19
You also tried option .silent() ?
.silent() activates the button and the switch
.quietOn() and .quietOff() only affects the button