Re: GarbageCalendar (new version) lua scripts
Posted: 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/
Open source Home Automation System
https://forum.domoticz.com/
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/
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?
Code: Select all
websitemodule="m_burgerportaal"
Zipcode="1111AA"
Housenr="11"
Housenrsuf= ""
BPName="rmn"
-- or --
BPName="assen"
-- or --
BPName="bar"
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:
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.
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.)
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 .. "'")
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")
? 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 .. "'")
No, that script will only be ran by the garbagecalendar process when there is a notification happening and that is not what you want.
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
}