Updating the status of Domoticz switches without triggering?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

tequila
Posts: 60
Joined: Tuesday 02 August 2016 17:08
Target OS: -
Domoticz version:
Contact:

Re: RE: Re: Updating the status of Domoticz switches without trigger

Post 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.
nigels0
Posts: 221
Joined: Thursday 23 January 2014 12:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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&param=udevice&idx=<IDX>&nvalue=0 
ON
/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=1
Andrex
Posts: 92
Joined: Thursday 18 February 2016 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Updating the status of Domoticz switches without trigger

Post 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&param=udevice&idx=<IDX>&nvalue=0 
ON
/json.htm?type=command&param=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.
bebeno
Posts: 3
Joined: Tuesday 24 January 2017 5:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
User avatar
sisaenkov
Posts: 50
Joined: Friday 27 May 2016 7:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8
Location: Moscow, Russia
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
Wob76
Posts: 110
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
nbleezi
Posts: 1
Joined: Friday 12 April 2019 17:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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.
Andrex
Posts: 92
Joined: Thursday 18 February 2016 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Updating the status of Domoticz switches without trigger

Post 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
jurgend
Posts: 9
Joined: Sunday 18 April 2021 13:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: RE: Re: Updating the status of Domoticz switches without trigger

Post 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!
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post by waltervl »

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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?
Bugs bug me.
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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().
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
open.jpg (15.26 KiB) Viewed 1156 times
closed.jpg
closed.jpg (14.11 KiB) Viewed 1156 times
empty.jpg
empty.jpg (14.2 KiB) Viewed 1156 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
Bugs bug me.
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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() ?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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&param=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 
Bugs bug me.
HvdW
Posts: 617
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Updating the status of Domoticz switches without triggering?

Post 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
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest