nighttime not working

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

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

nighttime not working

Post by poudenes »

Hi All,

In Domoticz i have my location so have a sunset and sunrise time in dashboard.
have this dzEvent script but it does not work its also running in daytime.
Can someone assist me?

Code: Select all

return {
    active = true,
    on = {
		timer = {'at nighttime'},
        devices = {'Keuken Sensor'}
    },
    execute = function(domoticz, device)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT OFF WHEN GONNA SLEEP	
    if
    domoticz.devices('Full Handmatige Modus').state == 'Off' and
    domoticz.devices('Scene Goodnight').state == 'On' and
    domoticz.devices('Keuken Sensor').state == 'Off' and 
    domoticz.devices('Kookplaat').state == 'On'
    then
        domoticz.devices('Kookplaat').switchOff().afterSec(3)
        domoticz.log('--==<[GOODNIGHT AAN KEUKEN LICHT UIT]>==--', domoticz.LOG_FORCE)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT ON WHEN KODI IS OFF	        
    elseif
    domoticz.devices('Keuken Sensor').state == 'On' and
    domoticz.devices('Kodi').state == 'Off' and
    domoticz.devices('Kookplaat').state == 'Off'
    then
        domoticz.devices('Kookplaat').switchOn().afterSec(1)
        domoticz.log('--==<[KEUKEN SENSOR AAN KEUKEN LICHT AAN]>==--', domoticz.LOG_FORCE)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT OFF WHEN KODI IS OFF 	        
    elseif 
    domoticz.devices('Keuken Sensor').state == 'Off' and
    domoticz.devices('Kookplaat').state == 'On' and
    domoticz.devices('Kodi').state == 'Off'
    then
        domoticz.devices('Kookplaat').switchOff().afterSec(1)
        domoticz.log('--==<[KEUKEN SENSOR UIT KEUKEN LICHT UIT]>==--', domoticz.LOG_FORCE)
        end
    end
}
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
leby
Posts: 98
Joined: Monday 28 July 2014 9:58
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Stockholm
Contact:

Re: nighttime not working

Post by leby »

Think it's because you also have

Code: Select all

devices = {'Keuken Sensor'}
as trigger, the script will trigger on change on this sensor if I have understood it correctly.

if you change to

Code: Select all

return {
    active = true,
    on = {
		timer = {'at nighttime'}
    },
    execute = function(domoticz, device)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT OFF WHEN GONNA SLEEP	
    if
    domoticz.devices('Full Handmatige Modus').state == 'Off' and
    domoticz.devices('Scene Goodnight').state == 'On' and
    domoticz.devices('Keuken Sensor').state == 'Off' and 
    domoticz.devices('Kookplaat').state == 'On'
    then
        domoticz.devices('Kookplaat').switchOff().afterSec(3)
        domoticz.log('--==<[GOODNIGHT AAN KEUKEN LICHT UIT]>==--', domoticz.LOG_FORCE)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT ON WHEN KODI IS OFF	        
    elseif
    domoticz.devices('Keuken Sensor').state == 'On' and
    domoticz.devices('Kodi').state == 'Off' and
    domoticz.devices('Kookplaat').state == 'Off'
    then
        domoticz.devices('Kookplaat').switchOn().afterSec(1)
        domoticz.log('--==<[KEUKEN SENSOR AAN KEUKEN LICHT AAN]>==--', domoticz.LOG_FORCE)

-- ALWAYS NIGHTTIME ONLY --
-- KITCHEN LIGHT OFF WHEN KODI IS OFF 	        
    elseif 
    domoticz.devices('Keuken Sensor').state == 'Off' and
    domoticz.devices('Kookplaat').state == 'On' and
    domoticz.devices('Kodi').state == 'Off'
    then
        domoticz.devices('Kookplaat').switchOff().afterSec(1)
        domoticz.log('--==<[KEUKEN SENSOR UIT KEUKEN LICHT UIT]>==--', domoticz.LOG_FORCE)
        end
    end
}
it should only trigger at night..
/lennart
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: nighttime not working

Post by dannybloe »

You can restrict the device trigger to a time period as well:

Code: Select all

devices={ ['Keuken sensor'] ={'at nighttime'}]
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: nighttime not working

Post by poudenes »

Thanks both for the info.

So both are possible. 1 The whole execute at nighttime or specific on a device. Sounds interesting. Because i can combine some dzevent script now together.
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest