skip dzvents action at domoticz startup

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Newbie
Posts: 10
Joined: Thursday 06 April 2017 23:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

skip dzvents action at domoticz startup

Post by Newbie »

Version: Domoticz 2024.7 (build 16325)
Platform: DietPi 9.8.0 on Odroid C4
Plugin/Hardware: Generic sysfs GPIO, MQTT Auto Discovery Client Gateway with LAN interface, Satel Integra via LAN interface, Open Weather Map, Evohome via Web API, Kodi Media Server, Dummy (Does nothing, use for virtual switches only) .

Description: Hello all.
I did a script that turns on the entrance light when my satel integra is deactivate at nighttime or my blinds are closed. Here the code:

Code: Select all

return {
	on = {
        devices = { 'Satel INTEGRA' }
    },
    data = {
        contatore = { initial = 0 }
    },
    execute = function(domoticz, device)
        if (device.inActive and domoticz.data.contatore == 1) then
            local tapparelle = domoticz.devices('Tapparella cucina').level +
                               domoticz.devices('Tapparella sala').level +
                               domoticz.devices('Tapparella bagno SX').level +
                               domoticz.devices('Tapparella bagno DX').level +
                               domoticz.devices('Tapparella cameretta').level +
                               domoticz.devices('Tapparella camera da letto').level
            if (domoticz.time.matchesRule('at civilnighttime') or tapparelle == 0) then
                if domoticz.devices('Plafoniera corridoio').inActive then
                    domoticz.devices('Plafoniera corridoio').dimTo(100).forMin(5)
                end
            end
        end
        domoticz.data.contatore = 1
    end
}   
My goal is to prevent the light on at domoticz start, but this doesn't work. Light is always turned on as the "contatore" variable seems ignored.
What I'm doing wrong? Is there a better way to skip the first trigger at domoticz start?
solarboy
Posts: 320
Joined: Thursday 01 November 2018 19:47
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.6
Location: Portugal
Contact:

Re: skip dzvents action at domoticz startup

Post by solarboy »

There is a system trigger you could use documented here

https://wiki.domoticz.com/DzVents:_next ... %A6}_3.0.0

You could use it to trigger a script to turn off your light at boot time.
Intel NUC with Ubuntu Server VM (Proxmox),mosquitto(docker),RFXtrx433E,zwavejsUI (docker),Zigbee2mqtt(docker),SMA Hub (docker),Harmony Hub plugin, Kodi plugin,Homebridge(docker)+Google Home,APC UPS,SMA Modbus,Mitsubishi MQTT, Broadlink,Dombus
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: skip dzvents action at domoticz startup

Post by waltervl »

Your script is triggered at a change if device 'Satel INTEGRA'.
So if that device does not change at startup your script will not run. So indeed better use the system trigger to force to run the script at startup.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Newbie
Posts: 10
Joined: Thursday 06 April 2017 23:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: skip dzvents action at domoticz startup

Post by Newbie »

waltervl wrote: Sunday 17 November 2024 11:12 Your script is triggered at a change if device 'Satel INTEGRA'.
So if that device does not change at startup your script will not run. So indeed better use the system trigger to force to run the script at startup.
Well, every time domoticz starts, i receive a telegram alert with satel integra status. If I start domoticz with the alarm system armed, the script doesn't do anithing (correct), if the system is disarmed, lights are immediately switched on, so imho the satel change is triggered on startup, but the "contatore" 0 value in the first cycle is ignored,

Isn't the use of system start to turn off lights, a race condition with my script?
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: skip dzvents action at domoticz startup

Post by waltervl »

You only be sure when you put some logging in the script. See if it is triggered and what it reads. Now it is only guessing.
Also apparently something else is sending you a notification, not this script. So where is this notification coming from?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
madpatrick
Posts: 645
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: skip dzvents action at domoticz startup

Post by madpatrick »

I'm trying to activate a dz script after a restart of domoticz

Code: Select all

{
    on =
    {   
        timer =
            {
            function(domoticz)
                return
                    domoticz.time.matchesRule('at ' .. domoticz.variables('UV_Sleep').value) or
                    domoticz.time.matchesRule('at '  .. minutesBeforeSunset .. 'minutes before sunset')
                end,
            },

          devices = {Test,},
          system = {['start'] = { 'at 14:00 - 20:00'}} ,
          
        customEvents = {retrigger,}
    },
Only it does not start the script after a restart/start of Domoticz
Wgat am i doing wrong ?
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests