.afterMin not working  [SOLVED]

Moderator: leecollings

Post Reply
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

.afterMin not working

Post by RobbieT »

Hi,

I've a few scripts that use a .afterMin(). For some reason however this isn't working.
Example; I have the following script:

Code: Select all

--*------------------------------------------------------------------------------------*--
--Creator: Rob
--Date: 08-10-2019
--Last update: 16-10-2019
--Changelog: Added devices to trigger. Changed function segment. isTimer nog longer used
--Source: -
--Description: Turn on/off heating depending if someone is home or not
--*------------------------------------------------------------------------------------*--

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' } --Trigger is iemand thuis tussen tijd
        }
    },
     
--Voeg logging toe voor dit script  
   logging = {
   level = domoticz.LOG_INFO,
   marker = "Thermostaat automatisch"
   },

    execute = function(domoticz, device, item)
        --Declarations
        local Thuis = domoticz.devices(78) --Is er iemand thuis
        local Toon  = domoticz.devices(116) -- Toon Programma's
        
    --Function
    if(Thuis.active) then
    Toon.cancelQueuedCommands()
    Toon.switchSelector(30)
    domoticz.log('Toon is automatisch ingesteld op programma Thuis via dzVents')
    domoticz.notify('Thermostaat automatisch', 'Er is iemand thuis. De thermostaat is automatisch op het programma Thuis ingesteld.', 'domoticz.PRIORITY_LOW')
else
    Toon.switchSelector(10).afterMin(30)
    domoticz.log('Toon is automatisch ingesteld op programma Weg via dzVents')
    domoticz.notify('Thermostaat automatisch', 'Er is niemand thuis. De thermostaat is automatisch op het programma Weg ingesteld.', 'domoticz.PRIORITY_LOW')
    end
end
}
The thermostat (Toon) should go to program "Weg" when nobody's home. This should be done 30 minutes after nobody is home. The script but as soon as the virtual switch "Someone Home" is flipped the program "weg" is set instead of after 30 min.

Anyone got a fix for this?
Perhaps useful: I'm running Domoticz on my Synology with a package from Jdahl.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Monday 04 November 2019 15:55 I've a few scripts that use a .afterMin(). For some reason however this isn't working.
Perhaps useful: I'm running Domoticz on my Synology with a package from Jdahl.
I cannot replicate this on my systems (Raspberry and Synology) .
Can you share the log from when the switchSelector(xx).afterMin(xx) is triggered ?
Please also include your domoticz / dzVents version
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working

Post by RobbieT »

waaren wrote: Monday 04 November 2019 18:27
RobbieT wrote: Monday 04 November 2019 15:55 I've a few scripts that use a .afterMin(). For some reason however this isn't working.
Perhaps useful: I'm running Domoticz on my Synology with a package from Jdahl.
I cannot replicate this on my systems (Raspberry and Synology) .
Can you share the log from when the switchSelector(xx).afterMin(xx) is triggered ?
Please also include your domoticz / dzVents version
Hi Waaren,

I'm running Domoticz Version: 4.10717
Build Hash: b38b49e-modified
Compile Date: 2019-05-09 13:04:08
dzVents Version: 2.4.19

My log entry is as follows (in dutch)

Code: Select all

2019-11-04 14:23:54.059  (Ping) Lighting 2 (Telefoon Rob)
2019-11-04 14:23:54.079  Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-11-04 14:23:54.111  (Dummy Switches) Light/Switch (Iemand thuis)
2019-11-04 14:23:54.131  Status: dzVents: Info:  Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch: Device: "Iemand thuis (Dummy Switches)", Index: 78
2019-11-04 14:23:54.132  Status: dzVents: Info:  Thermostaat automatisch: Toon is automatisch ingesteld op programma Weg via dzVents
2019-11-04 14:23:54.132  Status: dzVents: Info:  Thermostaat automatisch: ------ Finished Thermostaat automatisch
2019-11-04 14:23:54.132  Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-11-04 14:23:54.151  Status: Notification: Thermostaat automatisch
2019-11-04 14:23:54.840  Notification sent (pushover) => Success

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Monday 04 November 2019 19:29 I'm running Domoticz Version: 4.10717
dzVents Version: 2.4.19

My log entry is as follows (in dutch)

Code: Select all

2019-11-04 14:23:54.132  Status: dzVents: Info:  Thermostaat automatisch: Toon is automatisch ingesteld op programma Weg via dzVents
2019-11-04 14:23:54.151  Status: Notification: Thermostaat automatisch
2019-11-04 14:23:54.840  Notification sent (pushover) => Success
Hi, I only see the loginfo message and the notification in the log but I don't see the selector changing state.
If it switched I expect to see something like
2019-11-04 14:23:54.840 (virtual) Light/Switch (<name of Toon programma Selectorswitch>)
Are you sure the selector actual switched immediate or could it be that you only saw the log and notification?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working

Post by RobbieT »

waaren wrote: Monday 04 November 2019 20:04
RobbieT wrote: Monday 04 November 2019 19:29 I'm running Domoticz Version: 4.10717
dzVents Version: 2.4.19

My log entry is as follows (in dutch)

Code: Select all

2019-11-04 14:23:54.132  Status: dzVents: Info:  Thermostaat automatisch: Toon is automatisch ingesteld op programma Weg via dzVents
2019-11-04 14:23:54.151  Status: Notification: Thermostaat automatisch
2019-11-04 14:23:54.840  Notification sent (pushover) => Success
Hi, I only see the loginfo message and the notification in the log but I don't see the selector changing state.
If it switched I expect to see something like
2019-11-04 14:23:54.840 (virtual) Light/Switch (<name of Toon programma Selectorswitch>)
Are you sure the selector actual switched immediate or could it be that you only saw the log and notification?
Changed logging to debug and got some more information: I'm sure the selecter immedialty switched. When I turned off my Wifi when in front of the Toon I see the program change.

Code: Select all

2019-11-05 08:15:19.377 Status: dzVents: Info: Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch: Device: "Iemand thuis (Dummy Switches)", Index: 78
2019-11-05 08:15:19.377 Status: dzVents: Debug: Thermostaat automatisch: Processing device-adapter for Toon Scenes: Switch device adapter
2019-11-05 08:15:19.377 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10
2019-11-05 08:15:19.377 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10 AFTER 1800 SECONDS
2019-11-05 08:15:19.377 Status: dzVents: Info: Thermostaat automatisch: Toon is automatisch ingesteld op programma Weg via dzVents
2019-11-05 08:15:19.377 Status: dzVents: Info: Thermostaat automatisch: ------ Finished Thermostaat automatisch
2019-11-05 08:15:19.378 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-11-05 08:15:19.397 Status: Notification: Thermostaat automatisch
Besides that, I also have another dzvents with .afterHour and that one isn't working also.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Tuesday 05 November 2019 8:18 Changed logging to debug and got some more information: I'm sure the selecter immedialty switched. When I turned off my Wifi when in front of the Toon I see the program change.
Sorry still don't see the actual switch here.
Besides that, I also have another dzvents with .afterHour and that one isn't working also.
Let's have a look at that after we found what is causing this. Can the Toon program selector also be switched by another script ?

Can you try this one (I added an extra trigger and some log statements to see what happens.

Code: Select all

--*------------------------------------------------------------------------------------*--
--Creator: Rob
--Date: 08-10-2019
--Last update: 16-10-2019
--Changelog: Added devices to trigger. Changed function segment. isTimer nog longer used
--Source: -
--Description: Turn on/off heating depending if someone is home or not
--*------------------------------------------------------------------------------------*--

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' }, --Trigger is iemand thuis tussen tijd
            116,
        }
    },
     
--Voeg logging toe voor dit script  
   logging = {
   level = domoticz.LOG_DEBUG,
   marker = "Thermostaat automatisch"
   },

    execute = function( domoticz, item )
        --Declarations
        local Thuis = domoticz.devices(78) --Is er iemand thuis
        local Toon  = domoticz.devices(116) -- Toon Programma's
        
        domoticz.log('State of ' .. Thuis.name .. ' is ' .. Thuis.state,domoticz.LOG_DEBUG)
        domoticz.log('State of ' .. Toon.name .. ' is ' .. Toon.state,domoticz.LOG_DEBUG)
        domoticz.log('Script is triggered by ' .. item.name,domoticz.LOG_DEBUG)
        
    
       if item == Toon then 
            domoticz.log(Toon.name .. ' was updated ! Was it this script ?' ,domoticz.LOG_DEBUG)
            return
        end
        
        --Function
        if Thuis.active then
            Toon.cancelQueuedCommands()
            Toon.switchSelector(30)
            domoticz.log('Toon is automatisch ingesteld op programma Thuis via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is iemand thuis. De thermostaat is automatisch op het programma Thuis ingesteld.', 'domoticz.PRIORITY_LOW')
        else
            Toon.switchSelector(10).afterSec(30)
            domoticz.log('Toon is automatisch ingesteld op programma Weg via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is niemand thuis. De thermostaat is automatisch op het programma Weg ingesteld.', 'domoticz.PRIORITY_LOW')
        end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working

Post by RobbieT »

waaren wrote: Tuesday 05 November 2019 9:01
RobbieT wrote: Tuesday 05 November 2019 8:18 Changed logging to debug and got some more information: I'm sure the selecter immedialty switched. When I turned off my Wifi when in front of the Toon I see the program change.
Sorry still don't see the actual switch here.
Besides that, I also have another dzvents with .afterHour and that one isn't working also.
Let's have a look at that after we found what is causing this. Can the Toon program selector also be switched by another script ?

Can you try this one (I added an extra trigger and some log statements to see what happens.

Code: Select all

--*------------------------------------------------------------------------------------*--
--Creator: Rob
--Date: 08-10-2019
--Last update: 16-10-2019
--Changelog: Added devices to trigger. Changed function segment. isTimer nog longer used
--Source: -
--Description: Turn on/off heating depending if someone is home or not
--*------------------------------------------------------------------------------------*--

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' }, --Trigger is iemand thuis tussen tijd
            116,
        }
    },
     
--Voeg logging toe voor dit script  
   logging = {
   level = domoticz.LOG_DEBUG,
   marker = "Thermostaat automatisch"
   },

    execute = function( domoticz, item )
        --Declarations
        local Thuis = domoticz.devices(78) --Is er iemand thuis
        local Toon  = domoticz.devices(116) -- Toon Programma's
        
        domoticz.log('State of ' .. Thuis.name .. ' is ' .. Thuis.state,domoticz.LOG_DEBUG)
        domoticz.log('State of ' .. Toon.name .. ' is ' .. Toon.state,domoticz.LOG_DEBUG)
        domoticz.log('Script is triggered by ' .. item.name,domoticz.LOG_DEBUG)
        
    
       if item == Toon then 
            domoticz.log(Toon.name .. ' was updated ! Was it this script ?' ,domoticz.LOG_DEBUG)
            return
        end
        
        --Function
        if Thuis.active then
            Toon.cancelQueuedCommands()
            Toon.switchSelector(30)
            domoticz.log('Toon is automatisch ingesteld op programma Thuis via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is iemand thuis. De thermostaat is automatisch op het programma Thuis ingesteld.', 'domoticz.PRIORITY_LOW')
        else
            Toon.switchSelector(10).afterSec(30)
            domoticz.log('Toon is automatisch ingesteld op programma Weg via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is niemand thuis. De thermostaat is automatisch op het programma Weg ingesteld.', 'domoticz.PRIORITY_LOW')
        end
end
}
Thanks Waaren,

I've added the code and here is the log output (set to Debug inside Domoticz settings)

Code: Select all

2019-11-05 09:15:07.905 Status: dzVents: Debug: - Device: Iemand thuis
2019-11-05 09:15:07.916 Status: dzVents: Info: Handling events for: "Iemand thuis", value: "Off"
2019-11-05 09:15:07.917 Status: dzVents: Info: Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch 2: Device: "Iemand thuis (Dummy Switches)", Index: 78
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Processing device-adapter for Toon Scenes: Switch device adapter
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: State of Iemand thuis is Off
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: State of Toon Scenes is Thuis
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Script is triggered by Iemand thuis
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10
2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10 AFTER 30 SECONDS
2019-11-05 09:15:07.917 Status: dzVents: Info: Thermostaat automatisch: Toon is automatisch ingesteld op programma Weg via dzVents
2019-11-05 09:15:07.917 Status: dzVents: Info: Thermostaat automatisch: ------ Finished Thermostaat automatisch 2
2019-11-05 09:15:07.917 Status: dzVents: Debug: Commands sent to Domoticz:
2019-11-05 09:15:07.917 Status: dzVents: Debug: - Toon Scenes = Set Level 10 AFTER 30 SECONDS
2019-11-05 09:15:07.917 Status: dzVents: Debug: - SendNotification = Thermostaat automatisch#Er is niemand thuis. De thermostaat is automatisch op het programma Weg ingesteld.#domoticz.PRIORITY_LOW#pushover##
2019-11-05 09:15:07.917 Status: dzVents: Debug: =====================================================
2019-11-05 09:15:07.917 Status: EventSystem: Script event triggered: /usr/local/domoticz/dzVents/runtime/dzVents.lua
2019-11-05 09:15:07.937 Status: Notification: Thermostaat automatisch
2019-11-05 09:15:08.500 Notification sent (pushover) => Success
2019-11-05 09:15:37.925 (Dummy Switches) Light/Switch (Toon Scenes)
2019-11-05 09:15:37.931 Status: dzVents: Debug: Dumping domoticz data to /usr/local/domoticz/var/scripts/dzVents/domoticzData.lua
2019-11-05 09:15:37.939 Status: dzVents: Debug: Processing device-adapter for Toon Scenes: Switch device adapter
2019-11-05 09:15:37.939 Status: dzVents: Debug: dzVents version: 2.4.19
2019-11-05 09:15:37.939 Status: dzVents: Debug: Event triggers:
2019-11-05 09:15:37.939 Status: dzVents: Debug: - Device: Toon Scenes
2019-11-05 09:15:37.950 Status: dzVents: Info: Handling events for: "Toon Scenes", value: "Weg"
2019-11-05 09:15:37.950 Status: dzVents: Info: Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch 2: Device: "Toon Scenes (Dummy Switches)", Index: 116
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: Processing device-adapter for Iemand thuis: Switch device adapter
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: State of Iemand thuis is Off
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: State of Toon Scenes is Weg
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: Script is triggered by Toon Scenes
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: Toon Scenes was updated ! Was it this script ?
2019-11-05 09:15:37.950 Status: dzVents: Info: Thermostaat automatisch: ------ Finished Thermostaat automatisch 2
2019-11-05 09:16:00.189 EventSystem: Sending SetPoint to device 'ToonThermostat' (18) ....
2019-11-05 09:16:00.191 (Dummy Switches) Thermostat (ToonThermostat)
2019-11-05 09:16:00.469 Status: dzVents: Debug: Processing device-adapter for ToonProgramInformation: Text device
2019-11-05 09:16:00.469 Status: dzVents: Debug: dzVents version: 2.4.19
2019-11-05 09:16:00.469 Status: dzVents: Debug: Event triggers:
2019-11-05 09:16:00.469 Status: dzVents: Debug: - Device: Temperatuur Binnen
2019-11-05 09:16:00.469 Status: dzVents: Debug: - Device: ToonThermostat
2019-11-05 09:16:00.469 Status: dzVents: Debug: - Device: ToonProgramInformation
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Tuesday 05 November 2019 9:17 I've added the code and here is the log output (set to Debug inside Domoticz settings)

Code: Select all

2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10 AFTER 30 SECONDS

2019-11-05 09:15:37.950 Status: dzVents: Info: Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch 2: Device: "Toon Scenes (Dummy Switches)", Index: 116
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: Toon Scenes was updated ! Was it this script ?
What I see in the log that the afterSec(30) works as expected. ( Minutes / hours in afterMin / afterHour are internally converted to seconds )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working

Post by RobbieT »

waaren wrote: Tuesday 05 November 2019 9:27
RobbieT wrote: Tuesday 05 November 2019 9:17 I've added the code and here is the log output (set to Debug inside Domoticz settings)

Code: Select all

2019-11-05 09:15:07.917 Status: dzVents: Debug: Thermostaat automatisch: Constructed timed-command: Set Level 10 AFTER 30 SECONDS

2019-11-05 09:15:37.950 Status: dzVents: Info: Thermostaat automatisch: ------ Start internal script: Thermostaat automatisch 2: Device: "Toon Scenes (Dummy Switches)", Index: 116
2019-11-05 09:15:37.950 Status: dzVents: Debug: Thermostaat automatisch: Toon Scenes was updated ! Was it this script ?
What I see in the log that the afterSec(30) works as expected. ( Minutes / hours in afterMin / afterHour are internally converted to seconds )
So this means?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Tuesday 05 November 2019 9:33 So this means?
It means that .afterSec(), .afterMin() and .afterHour() are working for this device.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working  [SOLVED]

Post by RobbieT »

waaren wrote: Tuesday 05 November 2019 9:35
RobbieT wrote: Tuesday 05 November 2019 9:33 So this means?
It means that .afterSec(), .afterMin() and .afterHour() are working for this device.
Well, the only thing really changed, is the begin

Code: Select all

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' }, --Trigger is iemand thuis tussen tijd
            116,
        }
    },
    
instead of

Code: Select all

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' } --Trigger is iemand thuis tussen tijd
        }
    },
(The 116 was added).

It looks like that that did the trick, or am I missing something?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: .afterMin not working

Post by waaren »

RobbieT wrote: Tuesday 05 November 2019 9:45 It looks like that that did the trick, or am I missing something?
Happy that it's working now but adding the 116 was just to show when the device actually changed. Nothing fundamentally changed in the script.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
RobbieT
Posts: 17
Joined: Thursday 13 December 2018 14:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: .afterMin not working

Post by RobbieT »

waaren wrote: Tuesday 05 November 2019 9:55
RobbieT wrote: Tuesday 05 November 2019 9:45 It looks like that that did the trick, or am I missing something?
Happy that it's working now but adding the 116 was just to show when the device actually changed. Nothing fundamentally changed in the script.
Ok. Strange strange..
It seems to be something inside the script. When I change your script without the debug log options it isn't working anymore. I changed it to this

Code: Select all

--*------------------------------------------------------------------------------------*--
--Creator: Rob
--Date: 08-10-2019
--Last update: 05-11-2019
--Changelog: 16-10-2019: Added devices to trigger. Changed function segment. isTimer no longer used | 05-11-2019: Trying to solve the .afterMin not working
--Source: -
--Description: Turn on/off heating depending if someone is home or not
--*------------------------------------------------------------------------------------*--

return {
    on = {
        devices = { 
            [78] =  { 'between 07:00 and 19:30' }, --Trigger is iemand thuis tussen tijd
            116,
        }
    },
     
	--Voeg logging toe voor dit script  
   logging = {
   level = domoticz.LOG_DEBUG,
   marker = "Thermostaat automatisch"
   },

    execute = function( domoticz, item )
        --Declarations
        local Thuis = domoticz.devices(78) --Is er iemand thuis
        local Toon  = domoticz.devices(116) -- Toon Programma's
        
    --Function
        if Thuis.active then
            Toon.cancelQueuedCommands()
            Toon.switchSelector(30)
            domoticz.log('Toon is automatisch ingesteld op programma Thuis via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is iemand thuis. De thermostaat is automatisch op het programma Thuis ingesteld.', 'domoticz.PRIORITY_LOW')
        else
            Toon.switchSelector(10).afterMin(2)
            domoticz.log('Toon is automatisch ingesteld op programma Weg via dzVents')
            domoticz.notify('Thermostaat automatisch', 'Er is niemand thuis. De thermostaat is automatisch op het programma Weg ingesteld.', 'domoticz.PRIORITY_LOW')
        end
end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest