Page 1 of 1

Help needed with script

Posted: Thursday 29 October 2020 15:47
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

Re: Help needed with script

Posted: Thursday 29 October 2020 17:43
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
}

Re: Help needed with script

Posted: Thursday 29 October 2020 19:09
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
}

Re: Help needed with script

Posted: Thursday 29 October 2020 19:52
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.

Re: Help needed with script  [Solved]

Posted: Thursday 29 October 2020 19:58
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