That is done in this topic (http://www.domoticz.com/forum/viewtopic ... 61&t=17963) Sharing : Afval kalendar in text sensor.
They have made a script that uses a website. However, in my homeplace, they do not use a website and want to try to get it together.
At this moment, I have a Dummy Switch in my domoticz that I wanted to use for this.
I have get the following code by reading several topic.
But how can i get it work so my switch is switching
Code: Select all
week = tonumber (os.date( "%V"))
dag = tostring(os.date("%a"));
status = tonumber(otherdevices_svalues['Afval'])
print('script bin_selector executed')
commandArray = {}
print ('Dag= '..dag)
if (dag=='Sat' or dag=='Sun' ) then
weekend = true; weekdag = false
end
if (dag=='Mon' or dag=='Tue' or dag=='Wed' or dag=='Thu' or dag=='Fri') then
weekend = false ; weekdag = true
end
--Bepalen morgen papier
if(week==2 and dag=='Wed' or week==4 and dag=='Wed' or week==6 and dag=='Wed' or week==8 and dag=='Wed' or week==10 and dag=='Wed' or week==12 and dag=='Wed' or week==14 and dag=='Wed' or week==16 and dag=='Wed' or week==18 and dag=='Wed' or week==20 and dag=='Wed' or week==22 and dag=='Wed' or week==24 and dag=='Wed' or week==26 and dag=='Wed' or week==28 and dag=='Wed'
or week==30 and dag=='Wed' or week==32 and dag=='Wed' or week==34 and dag=='Wed' or week==36 and dag=='Wed' or week==38 and dag=='Wed' or week==40 and dag=='Wed' or week==42 and dag=='Wed' or week==44 and dag=='Wed' or week==46 and dag=='Wed' or week==48 and dag=='Wed' or week==50 and dag=='Wed' or week==52 and dag=='Wed') then
morgenpapier = true; papier = false; plastic = false; niets = false
print ('morgen papier')
end
--Bepalen papier
if(week==2 and dag=='Thu' or week==4 and dag=='Thu' or week==6 and dag=='Thu' or week==8 and dag=='Thu' or week==10 and dag=='Thu' or week==12 and dag=='Thu' or week==14 and dag=='Thu' or week==16 and dag=='Thu' or week==18 and dag=='Thu' or week==20 and dag=='Thu' or week==22 and dag=='Thu' or week==24 and dag=='Thu' or week==26 and dag=='Thu' or week==28 and dag=='Thu'
or week==30 and dag=='Thu' or week==32 and dag=='Thu' or week==34 and dag=='Thu' or week==36 and dag=='Thu' or week==38 and dag=='Thu' or week==40 and dag=='Thu' or week==42 and dag=='Thu' or week==44 and dag=='Thu' or week==46 and dag=='Thu' or week==48 and dag=='Thu' or week==50 and dag=='Thu' or week==52 and dag=='Thu') then
morgenpapier = false; papier = true; plastic = false; niets = false
print ('vandaag papier morgen plastic')
end
--Bepalen plastic
if(week==2 and dag=='Fri' or week==4 and dag=='Fri' or week==6 and dag=='Fri' or week==8 and dag=='Fri' or week==10 and dag=='Fri' or week==12 and dag=='Fri' or week==14 and dag=='Fri' or week==16 and dag=='Fri' or week==18 and dag=='Fri' or week==20 and dag=='Fri' or week==22 and dag=='Fri' or week==24 and dag=='Fri' or week==26 and dag=='Fri' or week==28 and dag=='Fri'
or week==30 and dag=='Fri' or week==32 and dag=='Fri' or week==34 and dag=='Fri' or week==36 and dag=='Fri' or week==38 and dag=='Fri' or week==40 and dag=='Fri' or week==42 and dag=='Fri' or week==44 and dag=='Fri' or week==46 and dag=='Fri' or week==48 and dag=='Fri' or week==50 and dag=='Fri' or week==52 and dag=='Fri') then
morgenpapier = false; papier = false; plastic = true; niets = false
print ('vandaag plastic')
end
--Bepalen geen plastic en geen papier
if(dag=='Mon' or dag=='Tue' or dag=='Sat' or dag=='Sun') then
morgenpapier = false; papier = false; plastic = false; niets = true
print ('vandaag geen afval buiten zetten')
end
if (niets and dag) then
commandArray ['UpdateDevice']= '15|1|Geen ophaaldag'
end
if (morgenpapier and weekdag and dag) then
commandArray ['UpdateDevice']= '15|1|Morgen papier'
end
if (papier and weekdag and dag) then
commandArray ['UpdateDevice']= '15|1|Vandaag papier, morgen plastic'
end
if (plastic and weekdag and dag) then
commandArray ['UpdateDevice']= '15|1|Vandaag plastic'
end
return commandArray