Turn dummy switch on when domoticz starts up  [Solved]

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

Moderator: leecollings

Post Reply
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Turn dummy switch on when domoticz starts up

Post 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?
niki_lauda
Posts: 118
Joined: Saturday 31 August 2013 14:48
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Eindhoven (NL)
Contact:

Re: Turn dummy switch on when domoticz starts up

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Turn dummy switch on when domoticz starts up

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Turn dummy switch on when domoticz starts up

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
knireis
Posts: 16
Joined: Wednesday 09 April 2014 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by knireis »

waaren wrote: Sunday 13 September 2020 20:33 can you try this?
Hey thanks, now it works!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest