Time function is not executed

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

Moderator: leecollings

Post Reply
Backbone
Posts: 46
Joined: Thursday 22 October 2015 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: The Netherlands
Contact:

Time function is not executed

Post by Backbone »

I wrote a script for a thermostat that worked fine for 6 months.
Suddenly the time function is not executed anymore.
Nothing to be shown in the log when a time period is activated.

Only when I manually trigger the object where this timer is residing in from OFF to Normaal or vice versa it changes and the log reports the status change.

Simpel code...........

Code: Select all

if  dz.time.matchesRule('at 00:00-05:44') then
dz.devices(74).updateText ('00:00-05:44 @ 16.5 C - preset')
dz.log ('It works')
end
It must be simple as the script ran flawless and I did not change the code.
I cant remember Domoticz has been updated and this is the result.

Full code.........

Code: Select all

return
{
    
        --Thermostaat           -- =idx69   thermostat controller
        --CV_Brander            -- =idx67   cv burner switch
        --Temp_Kamer            -- =idx32   room temperature
        --Setpoint_Normaal      -- =idx68   regular temperature setpoint
        --Setpoint_Boost        -- =idx72   boost temperature setpoint
        --Setpoint_Boost_Tijd   -- =idx75   boost time
        --Thermostaat_Status    -- =idx74   textbox
    
    on =
    {
        devices = {'Thermostaat', 'CV_Brander', 'Temp_Kamer','Setpoint_Normaal','Setpoint_Boost','Setpoint_Boost_Tijd' },
    },

    execute = function(dz)

        local varTempReg = dz.variables('varTempReg') --declared as float value in settings menu
        
        varTempReg = dz.devices(68).setPoint 
        
        -- "Uit" mode active, initiated by thermostat switchselector at level 0
        if dz.devices(69).level == 0 then
           dz.devices(67).switchOff().checkFirst()
           dz.devices(74).updateText ('Thermostaat OFF')
           dz.log('Thermostat OFF')
        end

-- mon to thu

        -- "Normaal" mode active, initiated by thermostat switchselector at level 10
        if  dz.time.matchesRule('on mon,tue,wed,thu') then
            if dz.devices(69).level == 10 then
            if  dz.time.matchesRule('at 00:00-05:44') then
            dz.devices(74).updateText ('00:00-05:44 @ 16.5 C - preset')
                if dz.devices(32).temperature < 16.5 then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end

            if  dz.time.matchesRule('at 05:45-06:29') then
                dz.devices(74).updateText ('05:45-06:29 @ 16.5 C- preset')
                if dz.devices(32).temperature < 16.5 then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end
        
            if  dz.time.matchesRule('at 06:30-16:59') then
                dz.devices(74).updateText ('06:30-16:59 @ '..varTempReg..' C instelbaar')
                if dz.devices(32).temperature < dz.devices(68).setPoint then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end

            if  dz.time.matchesRule('at 17:00-19:29') then
                dz.devices(74).updateText ('17:00-19:29 @ 18 C - preset')
                    if dz.devices(32).temperature < 18 then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end
            
            if  dz.time.matchesRule('at 19:30-23:59') then
                dz.devices(74).updateText ('19:30-23:59 @ 16.5 C - preset')
                if dz.devices(32).temperature < 16.5 then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end
            
        end
end -- mon to thu

--fri to sun
 
     -- "Normaal" mode active, initiated by thermostat switchselector at level 10
    if dz.time.matchesRule('on fri,sat,sun') then
        if dz.devices(69).level == 10 then
            if  dz.time.matchesRule('at 00:00-07:29') then
                if dz.devices(32).temperature < 16.5 then
                    dz.devices(67).switchOn().checkFirst()
                    dz.devices(74).updateText ('00:00-07:29 @ 16.5 C - preset')
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end

            if  dz.time.matchesRule('at 07:30-16:59') then
                dz.devices(74).updateText ('07:30-16:59 @ '..varTempReg..' C instelbaar')
                if dz.devices(32).temperature < dz.devices(68).setPoint then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end

            if  dz.time.matchesRule('at 17:00-19:29') then
                dz.devices(74).updateText ('17:00-19:29 @ '..varTempReg..' C instelbaar')
                if dz.devices(32).temperature < dz.devices(68).setPoint then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end
            
            if  dz.time.matchesRule('at 19:30-23:59') then
                dz.devices(74).updateText ('19:30-23:59 @ 16.5 C - preset')
                if dz.devices(32).temperature < 16.5 then
                    dz.devices(67).switchOn().checkFirst()
                else
                    dz.devices(67).switchOff().checkFirst()
                end
            end
            
        end
    
    end --fri to sun
    end
 }    
User avatar
waltervl
Posts: 5770
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Time function is not executed

Post by waltervl »

What Domoticz version are you currently on (see menu Setup - About)
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
waltervl
Posts: 5770
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Time function is not executed

Post by waltervl »

For me it works.
I modified your simple code to get it to work on evenings

Code: Select all

return {
	on = {
		timer = {
			'every minute',
		}
	},
	logging = {
		level = domoticz.LOG_INFO,
		marker = 'timertest',
	},
	execute = function(domoticz, timer)
	  domoticz.log('Timer event was triggered by ' .. timer.trigger .. 'at time : ' .. domoticz.time.raw, domoticz.LOG_INFO)
	  if  domoticz.time.matchesRule('at 00:00-18:44') then
               -- dz.devices(74).updateText ('00:00-17:44 @ 16.5 C - preset')
               domoticz.log ('It works at time :'.. domoticz.time.raw)
           end
	end
}
Then in the log I see this:

Code: Select all

2025-04-30 18:43:00.069 dzVents: timertest: Timer event was triggered by every minuteat time : 2025-4-30 18:43:0.45
2025-04-30 18:43:00.069 dzVents: timertest: It works at time :2025-4-30 18:43:0.45
And after 18:44 i do not get the "It works" log entry as expected.

Perhaps something off with your time on your server?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Backbone
Posts: 46
Joined: Thursday 22 October 2015 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: The Netherlands
Contact:

Re: Time function is not executed

Post by Backbone »

Hello Walter,

Thanks for testing, so it must be in my setup.

Domoticz:
Version: 2024.7
Build Hash: b317cfab1
Compile Date: 2024-07-13 16:59:31
dzVents Version: 3.1.8
Python Version: 3.9.2 (default, Mar 12 2021, 04:06:34) [GCC 10.2.1 20210110]
Active User: admin

I thought about the summer/winter time but then it would give a 1 hour difference only.

I run domoticz on a Pi. No idea where to check the time you refer at.

Paco
Backbone
Posts: 46
Joined: Thursday 22 October 2015 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: The Netherlands
Contact:

Re: Time function is not executed

Post by Backbone »

put your code in and that works. I get the logs.

Code: Select all

2025-05-01 06:53:00.179 dzVents: timertest: Timer event was triggered by every minuteat time : 2025-5-1 6:53:0.52
2025-05-01 06:53:00.179 dzVents: timertest: It works at time :2025-5-1 6:53:0.52
But the trigger is on every minute.

My original trigger is

Code: Select all

    on =
    {
        devices = {'Thermostaat', 'CV_Brander', 'Temp_Kamer','Setpoint_Normaal','Setpoint_Boost','Setpoint_Boost_Tijd' },
    },

    execute = function(dz)
It worked before.
Is my assumption of how DZ works wrong?
User avatar
waltervl
Posts: 5770
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Time function is not executed

Post by waltervl »

In your case whenever one of the mentioned triggered devices is changed (by the integration or by the user interface or other scripts) the main script will run.
So if you do not see the script running at all then something has changed in changing the devices.
Also dzvents likes unique device names, so for example no 2 different devices with the same name "Thermostaat"
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest