lua help newbee

Moderator: leecollings

Post Reply
User avatar
rolandtwilt
Posts: 74
Joined: Monday 05 October 2020 18:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

lua help newbee

Post by rolandtwilt »

Hi, I am looking for a sript but I don't know where to start. I have a twilight switch, a motion detector and a floodlight. And now I would like the spotlight to come on when there is movement in the garden and it is dark. The individual components all work well, but how do I make them work together. I tried a blocky but it doesn't work well. Can someone help me? thank you in advance
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: lua help newbee

Post by waaren »

rolandtwilt wrote: Tuesday 30 March 2021 12:00 Hi, I am looking for a script but I don't know where to start. I have a twilight switch, a motion detector and a floodlight. And now I would like the spotlight to come on when there is movement in the garden and it is dark. The individual components all work well, but how do I make them work together. I tried a blocky but it doesn't work well. Can someone help me? thank you in advance
in dzVents (100% Lua) it could look below

__________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
___________________________________________________________________________________________________________________________

Code: Select all

return
{
    on =
    {
        devices =
        {
            'motion detector', -- change to name of your motion detector device
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all ok
        marker = 'Motion at night',
    },

    execute = function(dz, item)
        local isDark = dz.devices('twilight').active   -- change to name of twilight switch
        local spotLight = dz.devices('floodlight') -- change to name of spotlight / floodlight

        if item.active and isDark then
            spotLight.switchOn()
            spotLight.switchOff.afterSec(60) -- switch Off after 1 minute
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
rolandtwilt
Posts: 74
Joined: Monday 05 October 2020 18:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: lua help newbee

Post by rolandtwilt »

It works, I am happy! Very much thought, super! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest