Page 1 of 1

alarm action script not executed [SOLVED]

Posted: Tuesday 14 July 2020 12:12
by AllesVanZelf
Hello,
I had an alarmsystem working on Blockly. Recently I moved to DzVents. And I'm very happy with that move. But now I have something unexpected. One script won't trigger.

I have several scripts related to alarm. If there is an alarm (Alarm Home or Alarm Away) the dummy switches with the names 'Alarmsituatie Thuis', or 'Alarmsituatie Niet Thuis' are switched on. This is working well. But when one of these switches is turned on, I would expect some defined actions like I defined in below script. This script is turned On.

Code: Select all

return
{
     on =
     {
        devices =
        {
            'Alarmsituatie Thuis',
            'Alarmsituatie Niet Thuis',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },
    
    execute = function(dz)
        local alarmt = dz.devices('Alarmsituatie Thuis')
        local alarmnt = dz.devices('Alarmsituatie Niet Thuis')
        local sirene = dz.devices('Sirene Studeerkamer')
        local dialtone = dz.devices('BT-Play dialtone')

        dz.log('Alarmsituatie Thuis,   state: ' .. alarmt.state, dz.LOG_DEBUG)
        dz.log('Alarmsituatie Niet Thuis,   state: ' .. alarmnt.state, dz.LOG_DEBUG)
        dz.log('Sirene Studeerkamer,   state: ' .. sirene.state, dz.LOG_DEBUG)
        dz.log('BT-Play dialtone,   state: ' .. dialtone.state, dz.LOG_DEBUG)

        if alarmt.state == 'On' then
            sirene.switchOn().silent()
            dz.log('Alarm Thuis geactiveerd, maar Sirene niet aan', dz.LOG_INFO)
            dz.notify('Alarm', 'Alarm Thuis geactiveerd, maar sirene niet aan', dz.PRIORITY_HIGH, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)
 
        elseif alarmnt.state == 'On' then
            sirene.switchOn().silent()
            dz.notify('Alarm', 'niet Thuis geactiveerd, sirene aan!', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)
            dz.log('Alarm Thuis geactiveerd, Sirene aan!', dz.LOG_INFO)
            dialtone.switchOn().silent()
            
        end
    end
}
But it is not working. No Siren and no telegram. If I look in the log, this script is not even triggered. But I do not understand why not.
Do you see why this script is not triggered?

Re: alarm action script not executed

Posted: Tuesday 14 July 2020 12:30
by waaren
AllesVanZelf wrote: Tuesday 14 July 2020 12:12 I had an alarmsystem working on Blockly.

If I look in the log, this script is not even triggered. But I do not understand why not.
Do you see why this script is not triggered?
Are other dzVents scripts still working?
What are the names / types / subTypes of 'Alarmsituatie Thuis' and 'Alarmsituatie Niet Thuis' on the devices tab ?
How are the states switched of these devices ?
If you use the domoticz internal editor to write / save this script, what do you see in the log when you add a comment line and save it again?

Re: alarm action script not executed

Posted: Tuesday 14 July 2020 12:36
by AllesVanZelf
Image

I'm not sure if I understand your question. In the script where I switch on the dummy, it is switched like:
alarmt.switchOn().silent()
and they are switched on and off.

When I resave this script:

Code: Select all

 2020-07-14 12:35:06.881 Status: EventSystem: reset all events...
2020-07-14 12:35:06.891 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security-Alarm Tag reader DzVents.lua
2020-07-14 12:35:06.891 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security-Alarm Remote control buttons DzVents.lua
2020-07-14 12:35:06.892 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security-Alarm Thuis DzVents.lua
2020-07-14 12:35:06.892 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security-Alarm Niet Thuis DzVents.lua
2020-07-14 12:35:06.893 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security Alarm aan actie DzVents.lua
2020-07-14 12:35:06.893 Status: dzVents: Write file: /home/pi/domoticz/scripts/dzVents/generated_scripts/Security Alarm uit DzVents.lua
No errors

Re: alarm action script not executed

Posted: Tuesday 14 July 2020 14:38
by waaren
AllesVanZelf wrote: Tuesday 14 July 2020 12:36 alarmt.switchOn().silent()
The silent() prevents follow up events to be triggered

Re: alarm action script not executed

Posted: Tuesday 14 July 2020 15:31
by AllesVanZelf
Yess
That's it. I did not know that silent() was working from script to script.
Thanks a lot.

ps. How do you make the subject [SOLVED] with the link to the post? The

Code: Select all

[url=][/url]
does not work in the subject