Motion script not working

Moderator: leecollings

Post Reply
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Motion script not working

Post by Fredom »

Dear forum members,
Can anyone help me to get this script to work.
After many attempts I did manage to get no more error messages in the Domoticz log. But the script still doesn't work :( .

The script should turn on a switch on movement and turn off after a set time.

Code: Select all

return
{
    active = true,

    on =
    {
        devices = { 
                     '691', --Bewegingsensor  (Xiaomi Human Body Sensor)
                     '37',  --Camera kinderkamer (schakelaar)
                    },
    },
        execute = function(dz,motion)
        local motion = dz.devices('691')
        local cam    = dz.devices('37')

        if motion.state == 'On' and cam.active then
        domoticz.log('Motion state');
        return
        elseif not(cam.active) then
            cam.switchOn()
            domoticz.log('Cam state on');
            cam.switchOff().afterSec(30)
            domoticz.log('Cam state off');
         end
    end
}
thanks in advance
Fredom
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Motion script not working

Post by Fredom »

It's working now
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
McMelloW
Posts: 434
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

Re: Motion script not working

Post by McMelloW »

Fredom wrote: Tuesday 12 October 2021 15:00 It's working now
Did you also post the working script version?
Greetings McMelloW
Fredom
Posts: 160
Joined: Saturday 19 September 2020 21:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Krimpen aan den IJssel
Contact:

Re: Motion script not working

Post by Fredom »

McMelloW wrote: Thursday 24 February 2022 14:48
Fredom wrote: Tuesday 12 October 2021 15:00 It's working now
Did you also post the working script version?
This is the script now

Code: Select all

return
{
    on =
    {
        devices = { 
                     'Motion Beerus',  --Xiaomi Human Body Sensor
                     'Beerus',          --kaku schakelaar
                  },

    },
   execute = function(dz)
        local motion = dz.devices('Motion Beerus')
        local   lamp = dz.devices('Beerus') 

    if motion.state == 'On' and lamp.state == 'Off' then
        lamp.switchOn().repeatAfterSec(1, 2)
        lamp.switchOff().afterMin(5).silent().repeatAfterSec(1, 2)
    end
end
}
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest