Page 1 of 1

aftersec does not work anymore

Posted: Tuesday 26 February 2019 21:17
by elgringo
I have a lua script which is triggered via a scene. The script should put my receiver is a mode to listen to radio (and turn the tv off).

When the source of the receiver is not radio, it first switches it to radio and after a delay, set the correct volume

Script

Code: Select all


return {

  on = {
    active = true,
    scenes = { 'Radio' }
  },
  execute = function(domoticz)
    
    local additionalDelay = 0
    local additionalMarantzDelay = 1
    
    if (not domoticz.devices('Media Power').active) then
      additionalDelay = 50
    end
    
    if (domoticz.devices('Marantz - Bron').level == 0) then
      additionalMarantzDelay = 5
    end
    domoticz.log("Starting scene 'Radio' power delay:"..additionalDelay..", Marantz delay:"..additionalMarantzDelay, domoticz.LOG_FORCE)
    
    domoticz.devices('TV - Source').cancelQueuedCommands()
    domoticz.devices('TV - Mute').cancelQueuedCommands()
    domoticz.devices('Marantz - Bron').cancelQueuedCommands()
    domoticz.devices('Marantz - Volume').cancelQueuedCommands()
        
    domoticz.devices('Media Power').switchOn()
    domoticz.devices('TV - Source').switchOff().afterSec(additionalDelay)
    domoticz.devices('Marantz - Bron').switchSelector(10).afterSec(additionalDelay)
    
    domoticz.devices('Marantz - Volume').switchSelector(35).afterSec(additionalDelay+additionalMarantzDelay)
    
    
  end
}

script output:

Code: Select all

2019-02-26 21:13:49.069 Status: dzVents: Info: ------ Start external script: sceneRadio.lua: Scene: "Radio", Index: 7
2019-02-26 21:13:49.070 Status: dzVents: Debug: Processing device-adapter for Media Power: Switch device adapter
2019-02-26 21:13:49.071 Status: dzVents: Debug: Processing device-adapter for Marantz - Bron: Switch device adapter
2019-02-26 21:13:49.071 Status: dzVents: !Info: Starting scene 'Radio' power delay:0, Marantz delay:1
2019-02-26 21:13:49.073 Status: dzVents: Debug: Processing device-adapter for TV - Source: Switch device adapter
2019-02-26 21:13:49.074 Status: dzVents: Debug: Processing device-adapter for TV - Mute: Switch device adapter
2019-02-26 21:13:49.075 Status: dzVents: Debug: Processing device-adapter for Marantz - Volume: Switch device adapter
2019-02-26 21:13:49.075 Status: dzVents: Debug: Constructed timed-command: On
2019-02-26 21:13:49.075 Status: dzVents: Debug: Constructed timed-command: Off
2019-02-26 21:13:49.075 Status: dzVents: Debug: Constructed timed-command: Off AFTER 0 SECONDS
2019-02-26 21:13:49.075 Status: dzVents: Debug: Constructed timed-command: Set Level 10
2019-02-26 21:13:49.076 Status: dzVents: Debug: Constructed timed-command: Set Level 10 AFTER 0 SECONDS
2019-02-26 21:13:49.076 Status: dzVents: Debug: Constructed timed-command: Set Level 35
2019-02-26 21:13:49.076 Status: dzVents: Debug: Constructed timed-command: Set Level 35 AFTER 1 SECONDS
2019-02-26 21:13:49.076 Status: dzVents: Info: ------ Finished sceneRadio.lua
2019-02-26 21:13:49.076 Status: dzVents: Debug: Commands sent to Domoticz:
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Cancel = {["type"]="device", ["idx"]=288}
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Cancel = {["type"]="device", ["idx"]=84}
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Cancel = {["type"]="device", ["idx"]=87}
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Cancel = {["type"]="device", ["idx"]=64}
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Media Power = On
2019-02-26 21:13:49.076 Status: dzVents: Debug: - TV - Source = Off AFTER 0 SECONDS
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Marantz - Bron = Set Level 10 AFTER 0 SECONDS
2019-02-26 21:13:49.076 Status: dzVents: Debug: - Marantz - Volume = Set Level 35 AFTER 1 SECONDS
2019-02-26 21:13:49.077 Status: dzVents: Debug: =====================================================
But the set level command to 35 does not get executed.
When I start the script again, the source is radio so the additional delay is 0, the volume command gets executed.

The script did work a few domoticz versions back. Now I am on 10531 they do not work anymore.

Re: aftersec does not work anymore

Posted: Wednesday 27 February 2019 0:31
by Dnpwwo
Last night I had to revert to a saved beta backup from late January because a lot of my scripts stopped working, not just those containing delays.

To be clear, the scripts are straight lua (not dzVents) and ran without error but it appears as if the 'commandArray' is not being processed after the script completes.

Anyone else seeing this?

Re: aftersec does not work anymore

Posted: Wednesday 27 February 2019 2:07
by waaren
elgringo wrote: Tuesday 26 February 2019 21:17 I have a lua script which is triggered via a scene. The script should put my receiver is a mode to listen to radio (and turn the tv off).
The script did work a few domoticz versions back. Now I am on 10525 they do not work anymore.
What I see is that the set level 35 is send to domoticz. Maybe the cancel command is processed after the set level command or the script is triggered a second time immediately when the scene state changes ?

Re: aftersec does not work anymore

Posted: Wednesday 27 February 2019 18:02
by elgringo
waaren wrote: Wednesday 27 February 2019 2:07
elgringo wrote: Tuesday 26 February 2019 21:17 I have a lua script which is triggered via a scene. The script should put my receiver is a mode to listen to radio (and turn the tv off).
The script did work a few domoticz versions back. Now I am on 10525 they do not work anymore.
What I see is that the set level 35 is send to domoticz. Maybe the cancel command is processed after the set level command or the script is triggered a second time immediately when the scene state changes ?
Original the cancel was not there, but this was to try it fixes the problem. With or without the cancel commands the set level after 1 second never gets executed.

I did some further testing. And the aftersec functionality only does not work when triggering a python plugin (the receiver is controller by a python plugin). For zwave devices the functionality does work, and I therefore assume for all non python devices.

Re: aftersec does not work anymore

Posted: Saturday 02 March 2019 12:16
by elgringo
I 'fixed' the problem by performing a reboot. The reboot was caused by accident (I was cleaning... ;) ) after this it worked again.