How to cancel queued commandArray{} events Topic is solved

Moderator: leecollings

Post Reply
Daiii
Posts: 13
Joined: Saturday 12 August 2017 0:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: New Hampshire, USA
Contact:

How to cancel queued commandArray{} events

Post by Daiii »

I'm porting over some old LUA scripts from seven years ago, and am wondering if something has changed in the method for cancelling a queued commandArray{} event. Suppose we issue:

Code: Select all

commandArray[ 'MyDevice' ] = "On AFTER 30"
and then, a little later, we wish to remove that queued request that hasn't yet fired. Or, perhaps we don't even know for sure if there are any pending requests, but we just want to make sure the device remains in it's present state without generating any radio traffic. It used to be we could issue:

Code: Select all

commandArray[ 'MyDevice' ] = "" -- Empty string cancellation request
and it would clear all queued requests on MyDevice. This worked in 2017 for OpenZwave devices, but with Domoticz 2024.2 and ZWave-JS-UI 9.7.1 the Domoticz log shows:

Code: Select all

Error: ZWaveMqtt: Switch command not supported ( - zwavejs2mqtt_0xef7cfb02_3-37-1-currentValue/MyDevice)
where ZWaveMqtt is my Domoticz MQTT autodiscovery gateway.

So, it looks like the empty "" commandArray{} string has lost its former special meaning of clearing the device queue, and is now just seen as a bogus unsupported command. Oddly, it DOES still have the effect of cancelling queued events even though it is reported as an error. Also, I verified that no ZWave MQTT traffic is generated directly in response to issuing the empty string.

Is there some new commandArray{} syntax to cleanly request that a device's queue be internally cleared?

Thanks
User avatar
psubiaco
Posts: 194
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: How to cancel queued commandArray{} events

Post by psubiaco »

Hi,
commandArray is a "table" variable that the running script uses to send commands to Domoticz.
While the script is executing, it can add new entries, test if an entry exist, cancel entries, and so on.
When the script returns, commandArray is read by Domoticz.
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: How to cancel queued commandArray{} events

Post by jvdz »

I do not think there is an option to cancel an scheduled event with regular LUA, but it seems to be possible in DzVents with: cancelQueuedCommands()
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to cancel queued commandArray{} events

Post by Kedi »

Did you try?

Code: Select all

commandArray[ 'MyDevice' ] = "Cancel"
Logic will get you from A to B. Imagination will take you everywhere.
Daiii
Posts: 13
Joined: Saturday 12 August 2017 0:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: New Hampshire, USA
Contact:

Re: How to cancel queued commandArray{} events

Post by Daiii »

Thank you, everyone, for your replies. I am not using DzVents, but your combined comments led me to inspect MQTTAutoDiscover::SendSwitchCommand for clues, and it turns out that a variation on Kedi's suggestion sortof accomplishes what I'm after:

Code: Select all

commandArray[ 'MyDevice' ] = "Stop"
I'd tried sending "Cancel" but that still logs the "Switch command not supported" error. However, the MQTT code recognizes "Stop", does not throw an error, and does indeed clear the device queue as a side effect.

This seems usable on the surface, but non-MQTT switches might not recognize "Stop", and the method comes with an undesirable side effect: the "Stop" command is accompanied by outgoing MQTT traffic to ZWave-JS-UI, and I have no idea whether that's creating additional radio traffic. Since queued future requests are completely internal to Domoticz, I was hoping for some method of clearing a device queue that did not "leak out" at all.

The (approx seven year old) method of clearing a device's queue simply by writing an empty command string was really nice. Was that lovely feature removed intentionally? I may just give up on this and write my own implementations of AFTER and FOR. That would mimic how DzVents manages to provide cancelQueuedCommands() within it's own mechanism.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest