aftersec does not work anymore
Posted: 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).
When the source of the receiver is not radio, it first switches it to radio and after a delay, set the correct volume
Script
script output:
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.
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
}
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: =====================================================
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.