Help needed with script  [Solved]

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

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:

Help needed with script

Post by Fredom »

Can anyone help me with this script please to get this working.

I have already searched the wiki but found nothing to help me
I am getting errors from line 21 that I don't understand.

Code: Select all

--Schuifdeur open 'Kerstboom' aan na zonsondergang (dzVentz)

--Schuifdeur open at nighttime and ('Keuken led verlichting') is Off then ('kerstboom') switch on and
--After 10 min switch Off
--If ('Keuken led verlichting')is On, do nothing (i am at home)
--'Schuifdeur'is an Kerui D026

return {
	active = true,
	on = {
		devices = { 
			['Schuifdeur'] = { 'at nighttime' }
		}
	},
	execute = function(domoticz, door)
		local light = domoticz.devices('Kerstboom')
		local light = domoticz.devices('Keuken led verlichting')
      
		if (door.state == 'Alarm') and
		domoticz.devices(Booglamp.state=='On') then 
		do 'nothing'
		elseif domoticz.devices('Keuken led verlichting'state ==Off) then
		domoticz.devices('Kerstboom').switchOn()
		light.switchOff().afterMin(10)
		
			
		
		end
	end
}

Log

Code: Select all

2020-10-29 15:35:36.287 ...Vents/generated_scripts/Schuifdeur open licht aan test.lua:21: unexpected symbol near ''nothing''
2020-10-29 15:35:37.264 Error: dzVents: Error: (3.0.2) error loading module 'Schuifdeur open licht aan test' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Schuifdeur open licht aan test.lua':

Pi 3 B with
Raspian Buster and
Domoticz 2020,2
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Help needed with script

Post by waaren »

Fredom wrote: Thursday 29 October 2020 15:47 do 'nothing'
do 'nothing' ??

Can you try this? If not OK then please share what you see in the log

Code: Select all

--Schuifdeur open 'Kerstboom' aan na zonsondergang (dzVents)

--Schuifdeur open at nighttime and ('Keuken led verlichting') is Off then ('kerstboom') switch on and
--After 10 min switch Off
--If ('Keuken led verlichting')is On, do nothing (i am at home)
--'Schuifdeur'is an Kerui D026

return
{
    active = true,

    on =
    {
        devices =
        {
            ['Schuifdeur'] = { 'at nighttime' },
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,  -- change to error when all OK
        marker = 'allmost christmas',
    },

    execute = function(dz, door)
        local tree = dz.devices('Kerstboom')
        local light = dz.devices('Keuken led verlichting')
        local lamp = dz.devices('Booglamp')

        dz.log(door.name .. ': state is ' ..  door.state,dz.LOG_DEBUG)
        dz.log(tree.name .. ': state is ' ..  tree.state,dz.LOG_DEBUG)
        dz.log(light.name .. ': state is ' ..  light.state,dz.LOG_DEBUG)
        dz.log(lamp.name .. ': state is ' ..  lamp.state,dz.LOG_DEBUG)

        if door.state == 'Alarm' and  lamp.active then
            return
        elseif not(light.active) then
            tree.switchOn()
            tree.switchOff().afterMin(10)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
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: Help needed with script

Post by Fredom »

Hello Waaren, thank you for your quick response.
Now the 'Kerstboom' just goes on even when the 'Keuken led verlichting'is on.
Kestboom turns off after the 2 min.
There are no errors in the log.
Only the 'Kerstboom' should not be lit when the 'Keuken led verlichting' is on.

Code: Select all

--Schuifdeur open 'Kerstboom' aan na zonsondergang (dzVents)

--Schuifdeur open at nighttime and ('Keuken led verlichting') is Off then ('kerstboom') switch on and
--After 10 min switch Off
--If ('Keuken led verlichting')is On, do nothing (i am at home)
--'Schuifdeur'is an Kerui D026

return
{
    active = true,

    on =
    {
        devices =
        {
            ['Schuifdeur'] = { 'at nighttime' },
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,  -- change to error when all OK
        marker = 'allmost christmas',
    },

    execute = function(dz, door)
        local tree = dz.devices('Kerstboom')
        local light = dz.devices('Keuken led verlichting')
        local lamp = dz.devices('Booglamp')

        dz.log(door.name .. ': state is ' ..  door.state,dz.LOG_DEBUG)
        dz.log(tree.name .. ': state is ' ..  tree.state,dz.LOG_DEBUG)
        dz.log(light.name .. ': state is ' ..  light.state,dz.LOG_DEBUG)
        dz.log(lamp.name .. ': state is ' ..  lamp.state,dz.LOG_DEBUG)

        if door.state == 'Alarm' and  lamp.active then
            return
        elseif not(light.active) then
            tree.switchOn()
            tree.switchOff().afterMin(2)
        end
    end
}
Yours sincerely,
Fred

Rasberry Pi 3B+ - Debian Trixie - Domoticz 2025.2
RFLink - RFXCom - Zigbee (CC2531)
P1 Smart Meter - KaKu
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Help needed with script

Post by waaren »

Fredom wrote: Thursday 29 October 2020 19:09 Now the 'Kerstboom' just goes on even when the 'Keuken led verlichting'is on.
Kestboom turns off after the 2 min.
There are no errors in the log.
As asked in my previous post. :( If not OK yet share the loglines. That's why I added the debug lines.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
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: Help needed with script  [Solved]

Post by Fredom »

Hello Waaren, it works perfectly now.
I changed the lamp to light and then it worked

Thank you very much for your help
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