Notification for Garbage

Post Reply
mdo82
Posts: 10
Joined: Tuesday 17 November 2015 22:26
Target OS: -
Domoticz version:
Location: The Netherlands
Contact:

Notification for Garbage

Post by mdo82 » Wednesday 20 September 2017 20:00

I have found a topic on this forum, which has made a LUA script through a waste collection website to see which container is to be put outside.

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 :D

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

zicht
Posts: 174
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 3.8xxx
Location: NL
Contact:

Re: Notification for Garbage

Post by zicht » Thursday 21 September 2017 21:25

You are using the wrong format

Code: Select all

commandArray['UpdateDevice'] = 'IDX'..'|0|'..whatever_your_variable_is
IDX needs to be replaced by the idx of you text device
you can find it in the sensor/devices (apparaten) table
Just lookup in that table you text sensor write down the idx number and construct the above using your values.

It should work that way !
Good luck :)
Rpi & Win x64. Using : cam's,Nest,RFXCom,Kaku,LaCrosse,RFY,IsAlive,Dummy,Wether Underground, standard Lua, Curl on windows,Domoticz Android App & Tasker,

"The only source of knowledge is experience (A.Einstein)"

mdo82
Posts: 10
Joined: Tuesday 17 November 2015 22:26
Target OS: -
Domoticz version:
Location: The Netherlands
Contact:

Re: Notification for Garbage

Post by mdo82 » Friday 22 September 2017 13:28

Simply i had place the wrong hardware in my domoticz :roll:

He is working ;)

Image

I still have a question about this.
I see my script running every 10 seconds, I had set the main device at 24 hours.
How it comes that the script still runs every 10 seconds?
Or is this a general setting within domoticz?

How can I get it that it's only once in 24 runs instead of every 10 seconds?

Image

Is it also possible to change te image ?

zicht
Posts: 174
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 3.8xxx
Location: NL
Contact:

Re: Notification for Garbage

Post by zicht » Sunday 24 September 2017 11:51

Probably you have placed it in a device script.

You can place it in a time script to run once a minute but that's als not nice for the purpose.

time = os.date("*t")
if (time.hour==7 or time.hour==19) and time.min==0 then

the script

end

This would run the script twice a day in the moring and in the evening.
(i use this to send me a telegram reminder evening before and in the morning of the waiste day :D )

The image is (not yet) changeable for the text devices but you can include html with picture. In my experience that does not work nice, but has been some beta's agoo so maybe it works now in a better way.

note :
If you start experimenting and loose you text device due to this (had that before) just update it in a script with a one word text and it will reapear.
but maybe also that is improved in current versions.
Rpi & Win x64. Using : cam's,Nest,RFXCom,Kaku,LaCrosse,RFY,IsAlive,Dummy,Wether Underground, standard Lua, Curl on windows,Domoticz Android App & Tasker,

"The only source of knowledge is experience (A.Einstein)"

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest