GarbageCalendar (new version) lua scripts
Moderator: leecollings
-
- Posts: 9
- Joined: Saturday 31 August 2019 11:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: GarbageCalendar (new version) lua scripts
Kun je ook de Gemeente Assen toevoegen? Die zijn sinds 1-1-2024 overgestapt van Afvalwijzer naar https://21burgerportaal.mendixcloud.com/
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
I had a quick look there and used some postalcode/housnr combo to test, but the Afvalkalender doesn't give me any response.Jackb wrote: ↑Wednesday 03 January 2024 13:33 Kun je ook de Gemeente Assen toevoegen? Die zijn sinds 1-1-2024 overgestapt van Afvalwijzer naar https://21burgerportaal.mendixcloud.com/
Does it work for you, and if so, please share the details with me via PM so I can have a look?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 9
- Joined: Saturday 31 August 2019 11:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: GarbageCalendar (new version) lua scripts
Thanks for the quick response.jvdz wrote: ↑Wednesday 03 January 2024 14:05I had a quick look there and used some postalcode/housnr combo to test, but the Afvalkalender doesn't give me any response.Jackb wrote: ↑Wednesday 03 January 2024 13:33 Kun je ook de Gemeente Assen toevoegen? Die zijn sinds 1-1-2024 overgestapt van Afvalwijzer naar https://21burgerportaal.mendixcloud.com/
Does it work for you, and if so, please share the details with me via PM so I can have a look?
At the moment it does not work for me either. I also tried Reinigingsdienst Midden Nederland. That one also does not work at the moment. Looks like there is a problem with the site. Maybe try again tomorrow.
Edit: It seems to work again now, it's just a bit slow.
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
Turns out that Assen is using the burgerportaal website which is also used by RMN and BAR, and I have already an RMN module.
So i decided to rename the m_rmn to m_burgerportaal and adding an extra config field where you define which of these 3 garbage collectors you have like:
This update is committed to the latest github master branch, so download the latest version and give this a try please.
So i decided to rename the m_rmn to m_burgerportaal and adding an extra config field where you define which of these 3 garbage collectors you have like:
Code: Select all
websitemodule="m_burgerportaal"
Zipcode="1111AA"
Housenr="11"
Housenrsuf= ""
BPName="rmn"
-- or --
BPName="assen"
-- or --
BPName="bar"
This update is committed to the latest github master branch, so download the latest version and give this a try please.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 9
- Joined: Saturday 31 August 2019 11:34
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: GarbageCalendar (new version) lua scripts
It's works! Thanks, great work.
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
Maybe a stupid question but I try to follow this wiki.
I get stuck by
I put all the files in my lua folder.
If I try ' script_time_garbagecalendar.lua mydebug = true' I get 'command not found' What am I doing wrong?
I get stuck by
How do I do this?To allow for notifications and alternative text in the domoticz device, you need to define a line for each garbage type returned by the webrequest. To determine what these garbagetypes should be, you simply run the script the first time with variable "mydebug = true -- (true/false)". This will always process the datafile and tell you about the missing garbage types in the domoticz log like this:
I put all the files in my lua folder.
If I try ' script_time_garbagecalendar.lua mydebug = true' I get 'command not found' What am I doing wrong?
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
The Wiki page where you found that text starts with this:
After you have defined your address information and Garbage module, you run the script for the first time and the LOG file will tell you which garbage types are found and even give you an example for the entries to be made in your configfile for garbagetype_cfg = { .
In case you have issues, just email me a zip file containing your garbagecalendarconfig.lua and the generated log files in a zip file and I'll have a look for you.
So all information found on this page are setting to be done in your personal config file garbagecalendarconfig.lua.Create personal config
Go into directory "garbagecalendar/" and copy file "garbagecalendarconfig_model.lua" to "garbagecalendarconfig.lua" to create your personal config file. "garbagecalendarconfig.lua" will contain your personal setup and preferences used by the process. This file isn't updated when you upgrade the scripts from Github, so you will have to do this manually in case of changes/additions.
After you have defined your address information and Garbage module, you run the script for the first time and the LOG file will tell you which garbage types are found and even give you an example for the entries to be made in your configfile for garbagetype_cfg = { .
In case you have issues, just email me a zip file containing your garbagecalendarconfig.lua and the generated log files in a zip file and I'll have a look for you.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
Nice script, works fine!
What's the easiest way tot send a mqttmessage with ex. 'GFT, next friday). I've a button plus with a small display which works only with mqtt. How do I get only this (short) info out of this script to a topic?
What's the easiest way tot send a mqttmessage with ex. 'GFT, next friday). I've a button plus with a small display which works only with mqtt. How do I get only this (short) info out of this script to a topic?
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
Should be pretty simple....
Just define this field in your config: EventNotificationscript
Just define this field in your config: EventNotificationscript
This can shell the mosquitto_pub with the appropriate parameters or you can run an Lua or Shell script that does that.Notificationscript = '' -- Specify personal notification script/command eg: lua sendmessage.lua "@TEXT@" (where @TEXT@ will be replaced by the notification text.)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
I don't have much experience with this, so I hope someone can help me with this:
I have activated the above line in my script:

what is the next step now?
How do I setup 'notification_event_script.lua'? I don't wanna switch a lamp, I just want a simple mqtt topic out with day and type of garbagebin (ex. next friday, PMD)
I have activated the above line in my script:

what is the next step now?
How do I setup 'notification_event_script.lua'? I don't wanna switch a lamp, I just want a simple mqtt topic out with day and type of garbagebin (ex. next friday, PMD)
- Attachments
-
- Schermafbeelding 2024-02-17 om 16.34.40.jpg (286.23 KiB) Viewed 1281 times
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
Just update the example file and get rid of all you do not need and replace the logic by whatever you need in the script...
Could be as simple as this:
This script will send the formatted Notify_text, as defined in the config, to the topic you defined as TheRequiredTopic.
You can ofcourse also use any of the variables listed in the header to form your own message text.
I would advise to make a copy of the current 'notification_event_script.lua' and give it a new name to ensure it isn't overridden with upgrades.
Then define that new name in the configfile.
Could be as simple as this:
Code: Select all
-----------------------------------------------------------------------------------------------------------------
-- garbagecalendar notification script
--[[=== Available variables from the mainscript :
Notify_type = GarbageType as defined as key in "garbagetype_cfg" and coming from the internet.
Notify_text = Formed text sentence using the settings from the "notificationtext" field
Notify_date = Formatted notification date using the config variable "notificationdate"
Notify_mtitle = Formatted Title sentence using the settings from the "notificationtitle" field
Notify_mtext = Description from "garbagetype_cfg" "text" field
Notify_reminder = Formatted content for the config variable "notificationreminder"
]]
-- ensure they are all initialised to avoid errors.
Notify_type = Notify_type or ''
Notify_text = Notify_text or ''
Notify_date = Notify_date or ''
Notify_mtitle = Notify_mtitle or ''
Notify_mtext = Notify_mtext or ''
Notify_reminder = Notify_reminder or ''
-----------------------------------------------------------------------------------------------------------------
-- Start your logic here in the appropriate section
-----------------------------------------------------------------------------------------------------------------
os.execute("mosquitto_pub -h 127.0.0.1 -t 'TheRequiredTopic' -m '" .. Notify_text .. "'")
You can ofcourse also use any of the variables listed in the header to form your own message text.
I would advise to make a copy of the current 'notification_event_script.lua' and give it a new name to ensure it isn't overridden with upgrades.
Then define that new name in the configfile.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
thx!
I use the script above(and changed the name).
If I use Notify_text (os.execute("mosquitto_pub -h 127.0.0.1 -t 'TheRequiredTopic' -m '" .. Notify_text .. "'") )and change this in my config:
I only get: 'Groente, fruit en tuinafval' on my mqtttopiq. Why I don't get "@DATE@' in my topic referring to 'notificationtext = '@GARBAGETEXT@ @DAY@''
I use the script above(and changed the name).
If I use Notify_text (os.execute("mosquitto_pub -h 127.0.0.1 -t 'TheRequiredTopic' -m '" .. Notify_text .. "'") )and change this in my config:
I only get: 'Groente, fruit en tuinafval' on my mqtttopiq. Why I don't get "@DATE@' in my topic referring to 'notificationtext = '@GARBAGETEXT@ @DAY@''
- Attachments
-
- Schermafbeelding 2024-02-18 om 12.54.29.jpg (286.37 KiB) Viewed 1254 times
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
EDIT: Just tried to simulate and get something similar so will have a look and let you know. 

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
This issue is that I made a mistake in the description at the top, swapping the description for Notify_text and Notify_mtext, of the example script which should be:
So you need to change the script to:
...and all should work.
Code: Select all
--[[=== Available variables from the mainscript :
Notify_type = GarbageType as defined as key in "garbagetype_cfg" and coming from the internet.
Notify_text = Description from "garbagetype_cfg" "text" field
Notify_date = Formatted notification date using the config variable "notificationdate"
Notify_mtitle = Formatted Title sentence using the settings from the "notificationtitle" field
Notify_mtext = Formatted text sentence using the settings from the "notificationtext" field
Notify_reminder = Formatted content for the config variable "notificationreminder"
]]
Code: Select all
-----------------------------------------------------------------------------------------------------------------
-- garbagecalendar notification script
--[[=== Available variables from the mainscript :
Notify_type = GarbageType as defined as key in "garbagetype_cfg" and coming from the internet.
Notify_text = Description from "garbagetype_cfg" "text" field
Notify_date = Formatted notification date using the config variable "notificationdate"
Notify_mtitle = Formatted Title sentence using the settings from the "notificationtitle" field
Notify_mtext = Formatted text sentence using the settings from the "notificationtext" field
Notify_reminder = Formatted content for the config variable "notificationreminder"
]]
-- ensure they are all initialised to avoid errors.
Notify_type = Notify_type or ''
Notify_text = Notify_text or ''
Notify_date = Notify_date or ''
Notify_mtitle = Notify_mtitle or ''
Notify_mtext = Notify_mtext or ''
Notify_reminder = Notify_reminder or ''
-----------------------------------------------------------------------------------------------------------------
-- Start your logic here in the appropriate section
-----------------------------------------------------------------------------------------------------------------
os.execute("mosquitto_pub -h 172.18.0.3 -t 'TheRequiredTopic' -m '" .. Notify_mtext .. "' > test.log")
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
This does the job! Many thx!
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
One more small question. I now only receive a notification on my mqtt topic one day in advance that waste ' x' will be collected tomorrow (notificationtext = '@GARBAGETEXT@ @DAY@'). However, this will remain on my MQTT display until the following week. I would prefer to receive a daily notification with the correct reference when the next emptying is due (for example, in a week, in 6 days, in 5 days, etc.).
How could I set this up and where?
How could I set this up and where?
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
That is a different requirement than a notification, but you simply could build your own script that retrieves the text from your current TEXT DEVICE in Domoticz that contains the next 3 garbages collections and modify that to your needs. 

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
Ok thanks for your response. Doesn't sound that simple to me. I'm not very good at making scripts. Is there anyone who could help me on my way?
-
- Posts: 165
- Joined: Thursday 28 December 2017 14:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Broek op Langedijk
- Contact:
Re: GarbageCalendar (new version) lua scripts
If I understand correctly, I should use the script:
? what should this look like? to send an mqtt message every day? I'm a bit confused as to where I should set something now. I sent a one-time mqtt message in 'nano notification_event_script' with the line:nano notification_external_script.lua
os.execute("mosquitto_pub -h 10.0.1.122 -t 'Topic container' -m '" .. Notify_mtext .. "'")
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: GarbageCalendar (new version) lua scripts
No, that script will only be ran by the garbagecalendar process when there is a notification happening and that is not what you want.
What I meant was creating a dzvents script that will read the text in the GarbageCalendar text device, change that when required and send it as an MQTT message one time per day. something like this to give you an head start:
Code: Select all
return {
on = {
timer = {
-- 'every minute', --Use while changing the script -> causes the script to be called every minute
'at 8:00', -- specific time you want to send the MQTT
},
},
execute = function(dz, timer)
txt = dz.devices("Afval Kalender").text -- Get the current GabageCalendar text device information
l1txt = txt:match("[^\n]*") -- retrieve the first line from the text
dz.log('Full Afval schema:' .. txt, dz.LOG_INFO) -- show full text in domotics log
dz.log('Firstline Afval schema:' .. l1txt, dz.LOG_INFO) -- show first line text in domoticz log
-- os.execute("mosquitto_pub -h 10.0.1.122 -t 'Topic container' -m '" .. l1txt .. "'" -- uncomment to send the actual MQTT messages
end
}
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Who is online
Users browsing this forum: No registered users and 0 guests