Timer events start on the hour, every hour

User avatar
waaren
Posts: 15
Joined: Tuesday 03 January 2017 15:18
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Netherlands
Contact:

Timer events start on the hour, every hour

Postby waaren » Tuesday 10 January 2017 15:43

I use dzVents on my Synology 916+ (DSM6.1) with Domoticz version 3.6312 for a number of scripts. It's working great and simplifies the coding efforts a lot.
Looking at Domoticz logfile, I noticed that all my time based dzVents scripts are executed on the hour every hour, including the scripts with a timer setting in minutes that should not run on the hour (or I at least I did not expect it to do so)
Is this as designed or do I overlook something ?

Dishwasher.lua: ['timer'] = 'every 16 minutes'
Washer.lua: ['timer'] = 'every 17 minutes'
Blinds.lua: ['timer'] = 'every 29 minutes'

2017-01-10 12:00:00.546 LUA: >>> Handler: Dishwasher
2017-01-10 12:00:00.546 LUA: >>> Handler: Washer
2017-01-10 12:00:00.547 LUA: >>> Handler: Blinds
2017-01-10 13:00:00.153 LUA: >>> Handler: Dishwasher
2017-01-10 13:00:00.154 LUA: >>> Handler: Washer
2017-01-10 13:00:00.155 LUA: >>> Handler: Blinds

and

2017-01-10 13:00:00.153 LUA: >>> Handler: Dishwasher
2017-01-10 13:16:00.205 LUA: >>> Handler: Dishwasher
2017-01-10 13:32:00.149 LUA: >>> Handler: Dishwasher
2017-01-10 13:48:00.401 LUA: >>> Handler: Dishwasher
2017-01-10 14:00:00.089 LUA: >>> Handler: Dishwasher
2017-01-10 14:16:00.443 LUA: >>> Handler: Dishwasher
Synology DS916+, DSM 6.1. Domoticz 3.6, RFXtrx433e, P1, Youless, Harmony, Hue, HW Weather+Energy+Watermeter, Zwave (Aeotec ZW090 Stick , Fibaro motion, ST814 humidity. GW PowerNodes), dzVents, Bash, PHP, Python, MydomoAtHome, HA Bridge

gordonb3
Posts: 355
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby gordonb3 » Tuesday 10 January 2017 20:52

So essentially what you are saying is that the timer does work as expected, except that it is reset on the hour?
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.5814

User avatar
waaren
Posts: 15
Joined: Tuesday 03 January 2017 15:18
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby waaren » Wednesday 11 January 2017 0:45

That is a very good summary indeed.
Synology DS916+, DSM 6.1. Domoticz 3.6, RFXtrx433e, P1, Youless, Harmony, Hue, HW Weather+Energy+Watermeter, Zwave (Aeotec ZW090 Stick , Fibaro motion, ST814 humidity. GW PowerNodes), dzVents, Bash, PHP, Python, MydomoAtHome, HA Bridge

gordonb3
Posts: 355
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby gordonb3 » Wednesday 11 January 2017 10:06

Looks like an oversight at design time to me.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.5814

gordonb3
Posts: 355
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby gordonb3 » Wednesday 11 January 2017 10:35

Well now, here you go:

Code: Select all

   function self.isTriggerByMinute(m, testTime)
      local time = self.getNow(testTime)
      return (time.min / m == math.floor(time.min / m))
   end

This just tests whether the current minute is a full multiple of the fixed 'every nn minutes' value, which includes zero. i.e. the whole hour.

This is dzVents btw, not Domoticz.
Last edited by gordonb3 on Wednesday 11 January 2017 11:08, edited 1 time in total.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.5814

dannybloe
Posts: 517
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Timer events start on the hour, every hour

Postby dannybloe » Wednesday 11 January 2017 10:35

Indeed it was :mrgreen: Looking at the code:

Code: Select all

   function self.isTriggerByMinute(m, testTime)
      local time = self.getNow(testTime)
      return (time.min / m == math.floor(time.min / m))
   end


It sees if time.min can be devided by the interval (m). Of course that is bs :lol:

Ehm... now finding a solution that doesn't require state is kinda hard. So... if you have any ideas..
Creator dzVents - RPiB+ZWay - Aeotec MultiSensor (6x) - Fibaro/Popp/GreenWave wall plugs - TKB Home dimmer - Aeotec Door sensor - Toon - 2x FGD-212, 8x FGD-211, 3x Qubino Flush dimmers - EvoHome Wifi+HGI80 - ESPEasy

gordonb3
Posts: 355
Joined: Friday 22 January 2016 11:15
Target OS: Linux
Domoticz version: custom
Location: The Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby gordonb3 » Wednesday 11 January 2017 11:07

Beat you to it ;)

Without something of a data store (or 'state') I'd say the only method is to reference the original firing time. Calculate the difference, which will likely be in seconds, and check whether this value is within a 60 second range of a full multiple of the 'every nn minutes' value. Should work for the next twenty years.
Excito B3 running Gentoo Linux, P1, Rfxtrx433 to read and control TFA, KaKu, EvoHome RFG100
Custom patched Domoticz v3.5814

dannybloe
Posts: 517
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Timer events start on the hour, every hour

Postby dannybloe » Wednesday 11 January 2017 12:13

I could use the script storage solution that is being used by the persisted variables. Anyhow... in the coming days/weeks I don't think I have time to fix this (some house reconstruction work that needs to be finished first). But I will make a github ticket for this.

In the meantime I'd stick to intervals that do work given the current algorithm.
Creator dzVents - RPiB+ZWay - Aeotec MultiSensor (6x) - Fibaro/Popp/GreenWave wall plugs - TKB Home dimmer - Aeotec Door sensor - Toon - 2x FGD-212, 8x FGD-211, 3x Qubino Flush dimmers - EvoHome Wifi+HGI80 - ESPEasy

User avatar
waaren
Posts: 15
Joined: Tuesday 03 January 2017 15:18
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby waaren » Thursday 12 January 2017 1:02

Thx gordonb3 and dannybloe for looking into this. Much apreciated
Synology DS916+, DSM 6.1. Domoticz 3.6, RFXtrx433e, P1, Youless, Harmony, Hue, HW Weather+Energy+Watermeter, Zwave (Aeotec ZW090 Stick , Fibaro motion, ST814 humidity. GW PowerNodes), dzVents, Bash, PHP, Python, MydomoAtHome, HA Bridge

dannybloe
Posts: 517
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Timer events start on the hour, every hour

Postby dannybloe » Thursday 12 January 2017 16:11

dannybloe wrote:I could use the script storage solution that is being used by the persisted variables. Anyhow... in the coming days/weeks I don't think I have time to fix this (some house reconstruction work that needs to be finished first). But I will make a github ticket for this.

In the meantime I'd stick to intervals that do work given the current algorithm.


Or you create a s.tload of ['timer'] = 'at xx:xx' entries around the clock of course. Then it will only skip a beat at 00:00 probably.
Creator dzVents - RPiB+ZWay - Aeotec MultiSensor (6x) - Fibaro/Popp/GreenWave wall plugs - TKB Home dimmer - Aeotec Door sensor - Toon - 2x FGD-212, 8x FGD-211, 3x Qubino Flush dimmers - EvoHome Wifi+HGI80 - ESPEasy

User avatar
waaren
Posts: 15
Joined: Tuesday 03 January 2017 15:18
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Timer events start on the hour, every hour

Postby waaren » Friday 13 January 2017 16:29

@dannybloe Thanks. As a workaround I created some ['timer'] = 'at xx:xx' entries which, as a side effect, effectively lowered the number of calls to the scripts as I could narrow them to the hours I actually need.
Synology DS916+, DSM 6.1. Domoticz 3.6, RFXtrx433e, P1, Youless, Harmony, Hue, HW Weather+Energy+Watermeter, Zwave (Aeotec ZW090 Stick , Fibaro motion, ST814 humidity. GW PowerNodes), dzVents, Bash, PHP, Python, MydomoAtHome, HA Bridge


Return to “dzVents Lua Framework”

Who is online

Users browsing this forum: No registered users and 2 guests