![Wink ;)](./images/smilies/icon_e_wink.gif)
how can i write a script in order to run once only? like setup() in most mcu's
![Question :?:](./images/smilies/icon_question.gif)
![Idea :idea:](./images/smilies/icon_idea.gif)
Moderator: leecollings
exactly like mcu's where there is a setup() which runs to do some settings only once
You might want to look at dzVents system event Start
maybe it is required to shut a window at first to let the system know what the window state isjvdz wrote: ↑Wednesday 21 October 2020 13:42 The easiest way I would do it is to shell a script from the domoticz.sh script started by the service to do the required tasks. probably add a sleep in there for a couple of seconds to give Domoticz time to startup and then perform the tasks required.
Still not sure what it is you need to do a startup so am just thinking out loud here.
Jos
Not sure how your reply is an answer to my post.abdolhamednik wrote: ↑Wednesday 21 October 2020 14:34maybe it is required to shut a window at first to let the system know what the window state isjvdz wrote: ↑Wednesday 21 October 2020 13:42 The easiest way I would do it is to shell a script from the domoticz.sh script started by the service to do the required tasks. probably add a sleep in there for a couple of seconds to give Domoticz time to startup and then perform the tasks required.
Still not sure what it is you need to do a startup so am just thinking out loud here.
Jos
thanks waaren. i'm reading that...
i followed it and wrote this short script, test, but it was not successful...
Code: Select all
return {
on = {
devices = {
'<exact name of the switch>'
}
},
execute = function(domoticz, switch)
if (switch.state == 'On') then
domoticz.log('Hey! I am on!')
else
domoticz.log('Hey! I am off!')
end
end
}
Can you define not successful.. ?abdolhamednik wrote: ↑Thursday 22 October 2020 7:52 i followed it and wrote this short script, test, but it was not successful...
Yes, Of course. The switch is: R1(1.52)<8-3>[3]*waaren wrote: ↑Thursday 22 October 2020 7:56Can you define not successful.. ?abdolhamednik wrote: ↑Thursday 22 October 2020 7:52 i followed it and wrote this short script, test, but it was not successful...
Did you replace <exact name of the switch > with the name of your switch ?
What did you expect and hat happened. What is in the log?
When I use that name in the script and save it as dzVents, I seeabdolhamednik wrote: ↑Thursday 22 October 2020 8:12 when i switched on and off that in the switches tab of domoticz, i hoped to see: "Hi! i am on or off" in the log. but saw only " ... admin switched on R1(1.52)<8-3>[3]* ... " or sth like that
Code: Select all
2020-10-22 08:34:38.683 Status: User: Admin initiated a switch command (672/R1(1.52)<8-3>[3]*/On)
2020-10-22 08:34:38.911 Status: dzVents: Info: Handling events for: "R1(1.52)<8-3>[3]*", value: "On"
2020-10-22 08:34:38.911 Status: dzVents: Info: ------ Start internal script: Script #6: Device: "R1(1.52)<8-3>[3]* (Virtual)", Index: 672
2020-10-22 08:34:38.913 Status: dzVents: Info: Hey! I am on!
2020-10-22 08:34:38.914 Status: dzVents: Info: ------ Finished Script #6
Did you set your location details in [Setup][Settings][Systems] ? If not domoticz / dzVents cannot determine the local time and everything derived from it.abdolhamednik wrote: ↑Thursday 22 October 2020 9:39 2020-10-22 11:04:44.594 Error: EventSystem: in /home/pi/avisa/dzVents/runtime/dzVents.lua: /home/pi/avisa/dzVents/runtime/Avisa.lua:39: attempt to perform arithmetic on field 'sunsetInMinutes' (a nil value)
Users browsing this forum: No registered users and 0 guests