I use a script to turn my PC on or off with a fibaro push button.
With a single push a want to turn the PC on or off and with the double push i will cancel the script, but i don't understand wy the cancelQueuedCommands is not working
Code: Select all
if item.isDevice and device.name == 'Reset_PC' then
dz.devices('PC-2').cancelQueuedCommands()
dz.notify("Domoticz", "Uitschakelen Geannuleerd", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
Code: Select all
local myCustomEvent = 'delayedSwitchOffPC'
return
{
on =
{
devices =
{
'$PC_Boven',
'Reset_PC',
},
customEvents =
{
myCustomEvent,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = "PC Boven Aan/Uit"
},
execute = function(dz, item, device)
-- ****************************** Your settings below this line ***************************************************
local VerbruikPC = dz.devices('Verbruik PC')
dz.log("Actueel verbruik PC = " ..VerbruikPC.actualWatt)
-- ***********************************************************************************************************
if item.isDevice and device.name == 'Reset_PC' then
dz.notify("Domoticz", "Geannuleerd", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
elseif item.isDevice and dz.devices('PC-2').state == 'Off' then
dz.devices('PC-2').switchOn()
dz.notify("Domoticz", "PC Boven is aan", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
elseif item.isDevice and dz.devices('PC-2').state == 'On' then
dz.notify("Domoticz", "Controle of PC uitgaat !!!", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
dz.emitEvent(myCustomEvent,'ControleVerbruikPC').afterSec(300)
elseif item.data == 'ControleVerbruikPC' and VerbruikPC.actualWatt < 55 then
dz.devices('PC-2').switchOff()
dz.notify("Domoticz", "PC is uitgeschakeld!!!", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
elseif item.data == 'ControleVerbruikPC' and VerbruikPC.actualWatt > 56 then
dz.notify("Domoticz", "PC gaat niet uit, stroomverbruik is te hoog !!!", dz.PRIORITY_NORMAL,dz.SOUND_DEFAULT, "" , "telegram")
end
end
}