LUA: Summer / Winter from timeofday or other...
Moderator: leecollings
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Not sure I understand what you want that isn't working.
You say you want "4 dummys" ...explain what you mean with that please and maybe post what you have tried already so we have something to start from.
Jos
You say you want "4 dummys" ...explain what you mean with that please and maybe post what you have tried already so we have something to start from.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Dear Jos...
I have now 4 dummy for the seasons, they switch with a separate cron
this is the script:
Code: Select all
-- script_time_season.lua
-- The change of state is a fixed date:
-- Lente: 21 maart t/m 20 juni
-- Zomer: 21 juni t/m 20 september
-- Herfst: 21 september t/m 20 december
-- Winter: 21 december t/m 20 maart
-- The script is run once a time.day when the virtual switch 'time.day' gets flipped (every sunset & sunrise)
commandArray = {}
time = os.date("*t")
Seizoen = '????'
-- check once a minute for the season to change
if (time.month == 12 and time.day >= 21)
or (time.month == 1)
or (time.month == 2)
or (time.month == 3 and time.day < 21) then
Seizoen = 'D.M.: Winter'
elseif (time.month == 3)
or (time.month == 4)
or (time.month == 5)
or (time.month == 6 and time.day < 21) then
Seizoen = 'D.M.: Voorjaar'
elseif (time.month == 6)
or (time.month == 7)
or (time.month == 8)
or (time.month == 9 and time.day < 21) then
Seizoen = 'D.M.: Zomer'
elseif (time.month == 9)
or (time.month == 10)
or (time.month == 11)
or (time.month == 12 and time.day < 21) then
Seizoen = 'D.M.: Herfst'
else
print('Something wrong in the season logic :)')
end
if Seizoen ~= '????' and otherdevices[Seizoen] ~= 'On' then
-- reset all switches to Off
print('Het seizoen is veranderd, het is nu '..Seizoen)
commandArray['D.M.: Winter'] = 'Off'
commandArray['D.M.: Voorjaar'] = 'Off'
commandArray['D.M.: Zomer'] = 'Off'
commandArray['D.M.: Herfst'] = 'Off'
-- reset current season to On
commandArray[Seizoen] = 'On'
end
return commandArray
This is better for my cpu.
And i do have the script in the DB from Domoticz much easier then everytime after a problem setup all the crons etc..
And what i should like in Domoticz is option to switch a Dummy for all the months..
I see every strange option in the timer setting in a dummy switch
Only no month option.
So a option to set months in a dummy is a good looking new feature i think:
Someone did try it for me in DZ vents:
viewtopic.php?p=189175#p189175
Sorry i cannot script any thing so i hope you great guys...
Thanks
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Ah, ok, but why do you want to use 4 dummy switches in stead of simply using 1 text sensor called Seizoen and then setting it to Voorjaar/Zomer/Herfst/Winter.... So the same as the original script you used which sets a Variable? forget this question, went back in this thread and see we went through this already 2 years ago.
The below script should be close to set 4 dummy sensors... this one is without a general On/Off switch, just setting the 4 season switches.
Jos
The below script should be close to set 4 dummy sensors... this one is without a general On/Off switch, just setting the 4 season switches.
Jos
Code: Select all
-- script_time_season.lua
-- The change of state is a fixed date:
-- Lente: 21 maart t/m 20 juni
-- Zomer: 21 juni t/m 20 september
-- Herfst: 21 september t/m 20 december
-- Winter: 21 december t/m 20 maart
-- The script is run once a time.day when the virtual switch 'time.day' gets flipped (every sunset & sunrise)
commandArray = {}
time = os.date("*t")
-- check once a minute for the season to change
if (time.month == 12 and time.day >= 21)
or (time.month == 1)
or (time.month == 2)
or (time.month == 3 and time.day < 21) then
if otherdevices["D.M.: Winter"] == 'Off' then
commandArray['D.M.: Winter'] = 'On'
commandArray['D.M.: Voorjaar'] = 'Off'
commandArray['D.M.: Zomer'] = 'Off'
commandArray['D.M.: Herfst'] = 'Off'
end
elseif (time.month == 3)
or (time.month == 4)
or (time.month == 5)
or (time.month == 6 and time.day < 21) then
if otherdevices["D.M.: Voorjaar"] == 'Off' then
commandArray['D.M.: Winter'] = 'Off'
commandArray['D.M.: Voorjaar'] = 'On'
commandArray['D.M.: Zomer'] = 'Off'
commandArray['D.M.: Herfst'] = 'Off'
end
elseif (time.month == 6)
or (time.month == 7)
or (time.month == 8)
or (time.month == 9 and time.day < 21) then
if otherdevices["D.M.: Zomer"] == 'Off' then
commandArray['D.M.: Winter'] = 'Off'
commandArray['D.M.: Voorjaar'] = 'Off'
commandArray['D.M.: Zomer'] = 'On'
commandArray['D.M.: Herfst'] = 'Off'
end
elseif (time.month == 9)
or (time.month == 10)
or (time.month == 11)
or (time.month == 12 and time.day < 21) then
if otherdevices["D.M.: Herfst"] == 'Off' then
commandArray['D.M.: Winter'] = 'Off'
commandArray['D.M.: Voorjaar'] = 'Off'
commandArray['D.M.: Zomer'] = 'Of'
commandArray['D.M.: Herfst'] = 'On'
end
else
print('Something wrong in the season logic :)')
end
return commandArray
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Thanks give it a try...jvdz wrote: ↑Tuesday 21 August 2018 9:27 Ah, ok, but why do you want to use 4 dummy switches in stead of simply using 1 text sensor called Seizoen and then setting it to Voorjaar/Zomer/Herfst/Winter.... So the same as the original script you used which sets a Variable? forget this question, went back in this thread and see we went through this already 2 years ago.
The below script should be close to set 4 dummy sensors... this one is without a general On/Off switch, just setting the 4 season switches.
Jos
Code: Select all
-- script_time_season.lua -- The change of state is a fixed date: -- Lente: 21 maart t/m 20 juni -- Zomer: 21 juni t/m 20 september -- Herfst: 21 september t/m 20 december -- Winter: 21 december t/m 20 maart -- The script is run once a time.day when the virtual switch 'time.day' gets flipped (every sunset & sunrise) commandArray = {} time = os.date("*t") -- check once a minute for the season to change if (time.month == 12 and time.day >= 21) or (time.month == 1) or (time.month == 2) or (time.month == 3 and time.day < 21) then if otherdevices["D.M.: Winter"] == 'Off' then commandArray['D.M.: Winter'] = 'On' commandArray['D.M.: Voorjaar'] = 'Off' commandArray['D.M.: Zomer'] = 'Off' commandArray['D.M.: Herfst'] = 'Off' end elseif (time.month == 3) or (time.month == 4) or (time.month == 5) or (time.month == 6 and time.day < 21) then if otherdevices["D.M.: Voorjaar"] == 'Off' then commandArray['D.M.: Winter'] = 'Off' commandArray['D.M.: Voorjaar'] = 'On' commandArray['D.M.: Zomer'] = 'Off' commandArray['D.M.: Herfst'] = 'Off' end elseif (time.month == 6) or (time.month == 7) or (time.month == 8) or (time.month == 9 and time.day < 21) then if otherdevices["D.M.: Zomer"] == 'Off' then commandArray['D.M.: Winter'] = 'Off' commandArray['D.M.: Voorjaar'] = 'Off' commandArray['D.M.: Zomer'] = 'On' commandArray['D.M.: Herfst'] = 'Off' end elseif (time.month == 9) or (time.month == 10) or (time.month == 11) or (time.month == 12 and time.day < 21) then if otherdevices["D.M.: Herfst"] == 'Off' then commandArray['D.M.: Winter'] = 'Off' commandArray['D.M.: Voorjaar'] = 'Off' commandArray['D.M.: Zomer'] = 'Of' commandArray['D.M.: Herfst'] = 'On' end else print('Something wrong in the season logic :)') end return commandArray
Is it a time or a device lua?
And is it possible to switch a protected switch?
edit:
I try this.
As a lua all and a time and device
I set voorjaar to on, and the others to off....
So when the script works... it should switch to te summer.. i think?[ or is there a other time every minute i read.. ]
Only that is not happens
I see also no thing in the log..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
This needs to be time to run it one time each minute.
There will only be an entry in the log when the season changes.
Just try reading & understanding the logic as it will benefit you when you can follow what script do!
There will only be an entry in the log when the season changes.
Just try reading & understanding the logic as it will benefit you when you can follow what script do!
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
mmm I think i have to wait until 21-9 and the the switch is going to Herfst ?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Are the 4 switched set to to proper status, which is what the script does?
You could simply change their settings by changing the "D.M.: Zomer" to Off and see whether the script changes it back.
Jos
You could simply change their settings by changing the "D.M.: Zomer" to Off and see whether the script changes it back.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Jos
I set the switch yesterday to off...
And voorjaar to on So that's why is say when it is going to switch:-)
I set the switch yesterday to off...
And voorjaar to on So that's why is say when it is going to switch:-)
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
It should change at the next minute interval!
Are you getting any errors in the log for the script as it seems you have different devicenames in that image?
Jos
Are you getting any errors in the log for the script as it seems you have different devicenames in that image?
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Jos..
SORRY sorry..
I set after all my dummy's a D ....
So it is working GREAT!!!
Thanks..!!
I now iäm asking to much..
Only can you make a script voor all the months of a year?
Or build this is Domoticz???
I use some dummy's for the months of a year
Only now i am switching them manually [ cannot script ]
Looks a extra option in Domoticz.
I use them for my terrarium for the bearded dragon his winter period..
Or can i give it a try with this script:-)
In stead of zomer, voorjaar etc months?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Nice..
Sounds like a nice challenge... It is really not that difficult, just to start is the hard thing.
So what exactly are you looking for? You really want 12 Dummy Switches for this?
You mentioned you already have switches you use manually? What are their names?
So: Lets first get the requirements layed out properly before starting to design something.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Jos,
I did give it a try
And i am happy en proud with myself:
12 dummy's
And looks working great
THANKS...
I did give it a try
And i am happy en proud with myself:
Code: Select all
-- script_time maanden.lua
commandArray = {}
time = os.date("*t")
-- check once a minute for the months to change
if (time.month == 1) then
if otherdevices["D.M.: Januari D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'On'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 2) then
if otherdevices ["D.M.: Februari D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'On'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 3) then
if otherdevices ["D.M.: Maart D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'On'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 4) then
if otherdevices ["D.M.: April D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'On'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 5) then
if otherdevices ["D.M.: Mei D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'On'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 6) then
if otherdevices ["D.M.: Juni D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'On'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 7) then
if otherdevices ["D.M.: Juli D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'On'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 8) then
if otherdevices ["D.M.: Augustus D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'On'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 9) then
if otherdevices ["D.M.: September D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'On'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 10) then
if otherdevices ["D.M.: Oktober D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'On'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 11) then
if otherdevices ["D.M.: November D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'On'
commandArray['D.M.: December D'] = 'Off'
end
elseif (time.month == 12) then
if otherdevices ["D.M.: December D"] == 'Off' then
commandArray['D.M.: Januari D'] = 'Off'
commandArray['D.M.: Februari D'] = 'Off'
commandArray['D.M.: Maart D'] = 'Off'
commandArray['D.M.: April D'] = 'Off'
commandArray['D.M.: Mei D'] = 'Off'
commandArray['D.M.: Juni D'] = 'Off'
commandArray['D.M.: Juli D'] = 'Off'
commandArray['D.M.: Augustus D'] = 'Off'
commandArray['D.M.: September D'] = 'Off'
commandArray['D.M.: Oktober D'] = 'Off'
commandArray['D.M.: November D'] = 'Off'
commandArray['D.M.: December D'] = 'On'
end
else
print('Er is iets mis in het script van Maanden :)')
end
return commandArray
And looks working great
THANKS...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Nice
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Thanks
Perhaps it is not the best way to do..
Only i am proud of it
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
There are always other, some might say better, ways to get there but more important is you get there and understand how you got there!
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
mmm
Here i am again...
My boys do have a bearded dragon...
And for his sleaping time i need the weeks of the year...
So i can set his UV time etc etc
In the winter he needs les uv light then in summer...
So is there someone that give me a example script where i can make the weeks of a year..
And when whe are on this point...
Days also should be great...
months weeks days.. i think there is no more left..
Here i am again...
My boys do have a bearded dragon...
And for his sleaping time i need the weeks of the year...
So i can set his UV time etc etc
In the winter he needs les uv light then in summer...
So is there someone that give me a example script where i can make the weeks of a year..
And when whe are on this point...
Days also should be great...
months weeks days.. i think there is no more left..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
-
- Posts: 65
- Joined: Friday 18 March 2016 10:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Just a serious, very late pick-up on this topic .. Sorry for that ..niki_lauda wrote: ↑Monday 26 June 2017 10:39How do I get, in lua, the content 'Seizoen'. One thing what I would like to do is not to set the level to 20 when its already set to 20.Martijn85 wrote:Thanks for the update/tweak!
That would be nice indeed! For now i have added this:mikeoo wrote:Only the PRINT command is now logged every minute. Still looking for a way to adjust it to only once.
Now it's running every 12 hours, not every minute.Code: Select all
-- check every 720 minutes for the season to change if((time.min % 720)==0) then end
The complete script:
Code: Select all
-- script_time_season.lua -- The change of state is a fixed date: -- Lente: 21 maart t/m 20 juni -- Zomer: 21 juni t/m 20 september -- Herfst: 21 september t/m 20 december -- Winter: 21 december t/m 20 maart commandArray = {} time = os.date("*t") -- check every 720 minutes for the season to change if((time.min % 720)==0) then -- check once a minute for the season to change if (time.month == 12 and time.day >= 21) or (time.month == 1) or (time.month == 2) or (time.month == 3 and time.day < 21) then Seizoen = 'Winter' elseif (time.month == 3) or (time.month == 4) or (time.month == 5) or (time.month == 6 and time.day < 21) then Seizoen = 'Lente' elseif (time.month == 6) or (time.month == 7) or (time.month == 8) or (time.month == 9 and time.day < 21) then Seizoen = 'Zomer' elseif (time.month == 9) or (time.month == 10) or (time.month == 11) or (time.month == 12 and time.day < 21) then Seizoen = 'Herfst' else print('<font color="red">Logica van de seizoenen kloppen niet!!!</font>') end if Seizoen == 'Lente' then commandArray['Seizoen'] = 'Set Level: 10' print('<font color="blue">Seizoen aangepast naar Lente</font>') elseif Seizoen == 'Zomer' then commandArray['Seizoen'] = 'Set Level: 20' print('<font color="blue">Seizoen aangepast naar Zomer</font>') elseif Seizoen == 'Herfst' then commandArray['Seizoen'] = 'Set Level: 30' print('<font color="blue">Seizoen aangepast naar Herfst</font>') elseif Seizoen == 'Winter' then commandArray['Seizoen'] = 'Set Level: 40' print('<font color="blue">Seizoen aangepast naar Winter</font>') else print('<font color="blue">Geen actie nodig voor het aanpassen van de seizoenen</font>') end end return commandArray
If I understand correctly, all I have to do is.
1. Copy Lua script and paste into new Lua script
2. Create a dummy switch with the name (seizoen), then create a selector with the names (lente,zomer,herfst,winter)
Or do I also have to do something in the user variables?
Raspberry 4 - USB boot Domoticz /|\ Raspberry 2B - Dashticz /|\ Tasmota device's /|\ Philips Hue & Yeelight
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
Yes: Create a TIME Script and Selector Switch named 'Seizoen'.
nope
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 65
- Joined: Friday 18 March 2016 10:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
OK, Cool for now..
And now only select once the season? And the rest go's automatic?
so this is what it looks like
Raspberry 4 - USB boot Domoticz /|\ Raspberry 2B - Dashticz /|\ Tasmota device's /|\ Philips Hue & Yeelight
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: LUA: Summer / Winter from timeofday or other...
I see it will currently update the selector switch every 720 seconds. The below code will simply update when it is changed/wrong.
Code: Select all
-- script_time_season.lua
-- The change of state is a fixed date:
-- Lente: 21 maart t/m 20 juni
-- Zomer: 21 juni t/m 20 september
-- Herfst: 21 september t/m 20 december
-- Winter: 21 december t/m 20 maart
commandArray = {}
-- check once a minute for the season to change
if (time.month == 12 and time.day >= 21)
or (time.month == 1)
or (time.month == 2)
or (time.month == 3 and time.day < 21) then
Seizoen = 'Winter'
elseif (time.month == 3)
or (time.month == 4)
or (time.month == 5)
or (time.month == 6 and time.day < 21) then
Seizoen = 'Lente'
elseif (time.month == 6)
or (time.month == 7)
or (time.month == 8)
or (time.month == 9 and time.day < 21) then
Seizoen = 'Zomer'
elseif (time.month == 9)
or (time.month == 10)
or (time.month == 11)
or (time.month == 12 and time.day < 21) then
Seizoen = 'Herfst'
else
print('<font color="red">Logica van de seizoenen kloppen niet!!!</font>')
end
if Seizoen == 'Lente' and otherdevices_svalues['Seizoen'] ~= '10' then
commandArray['Seizoen'] = 'Set Level: 10'
print('<font color="blue">Seizoen aangepast naar Lente</font>')
elseif Seizoen == 'Zomer' and otherdevices_svalues['Seizoen'] ~= '20' then
commandArray['Seizoen'] = 'Set Level: 20'
print('<font color="blue">Seizoen aangepast naar Zomer</font>')
elseif Seizoen == 'Herfst' and otherdevices_svalues['Seizoen'] ~= '30' then
commandArray['Seizoen'] = 'Set Level: 30'
print('<font color="blue">Seizoen aangepast naar Herfst</font>')
elseif Seizoen == 'Winter' and otherdevices_svalues['Seizoen'] ~= '40' then
commandArray['Seizoen'] = 'Set Level: 40'
print('<font color="blue">Seizoen aangepast naar Winter</font>')
else
print('<font color="blue">Geen actie nodig voor het aanpassen van de seizoenen</font>')
end
return commandArray
Last edited by jvdz on Tuesday 13 October 2020 11:10, edited 1 time in total.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Who is online
Users browsing this forum: No registered users and 1 guest