Page 1 of 1

Turn dummy switch on when domoticz starts up

Posted: Sunday 13 September 2020 20:13
by knireis
I'm trying to get a dzVents script going which turns a switch on when domoticz starts up.
But i am quite a noob in scripting and can not get it to work.
And i can not find a likewise example on the internet.
This i made sofar but it does not do the trick. (Linphone-S is the switch)

Code: Select all

return {
	on = {
		system = {
			'start',
		}
		devices = {'Linphone-S'
          }
	},
	execute = function(domoticz, switch)
	domoticz.switches('Linphone-S').switchOn()
	
	end
}
the log:
Spoiler: show

Code: Select all

2020-09-13 20:34:07.969 Error: dzVents: Error: (3.0.12) error loading module 'linphone-init' from file '/opt/domoticz/scripts/dzVents/generated_scripts/linphone-init.lua':
2020-09-13 20:34:07.969 ...ticz/scripts/dzVents/generated_scripts/linphone-init.lua:6: '}' expected (to close '{' at line 2) near 'devices'
Any suggestions?

Re: Turn dummy switch on when domoticz starts up

Posted: Sunday 13 September 2020 20:30
by niki_lauda
Maybe you can scan the log file for a restart and flip the switch.
viewtopic.php?f=61&t=28299&hilit=getDom ... og#p216802

Re: Turn dummy switch on when domoticz starts up

Posted: Sunday 13 September 2020 20:33
by waaren
knireis wrote: Sunday 13 September 2020 20:13 I'm trying to get a dzVents script going which turns a switch on when domoticz starts up.
Any suggestions?
can you try this?

Code: Select all

return
{
    on =
    {
        system =
        {
            'start',
        },
    },

    logging =
    {   
        level = domoticz.LOG_DEBUG,
        marker = 'start',
    },

    execute = function(dz)
        dz.devices('Linphone-S').switchOn()
    end
}

Re: Turn dummy switch on when domoticz starts up

Posted: Sunday 13 September 2020 20:35
by waaren
niki_lauda wrote: Sunday 13 September 2020 20:30 Maybe you can scan the log file for a restart and flip the switch.
viewtopic.php?f=61&t=28299&hilit=getDom ... og#p216802
If you are on dzVents version >= 3.0 that's no longer needed. See example in my previous post.

Re: Turn dummy switch on when domoticz starts up  [Solved]

Posted: Sunday 13 September 2020 20:42
by knireis
waaren wrote: Sunday 13 September 2020 20:33 can you try this?
Hey thanks, now it works!