-
Notifications
You must be signed in to change notification settings - Fork 2
Setup
-
lua must be installed which can be checked by running the following command: lua -v
Install lua52 in case it isn't installed yet. - curl must be installed which can be checked by running the following command: curl --version
-
Create a Dummy Text Sensor in Domoticz and give it an appropriate name: eg "Container".
This Text device will be filled with the upcoming garbage collextion schedule. -
Download the project zipfile and unzip the main script "script_time_garbagecalendar.lua" and "garbagecalendar" directory to one of these 2 directories:
-
"domoticz/scripts/lua" directory to use the standard LUA event system.
-or- - "domoticz/scripts/dzvents/scripts" directory in case you want to run the script with DzVents
In case you are using the Domoticz Docker container, you simply copy the scripts into container directory:
-
"/opt/domoticz/config/scripts/lua" directory to use the standard LUA event system.
-or- - "/opt/domoticz/scripts/dzvents/scripts" directory in case you want to run the script with DzVents
The data directory will be created in the garbagecalender subdirectory by default, which will contain the logs and retrieved data.
You could also specify your own data directory in the config file as defined in a later step on this page. -
"domoticz/scripts/lua" directory to use the standard LUA event system.
-
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.
-
Edit the following information in file "garbagecalendarconfig.lua":
-
-- Specify your information here as needed for your needs myGarbageDevice = '' -- The Text devicename in Domoticz. eg 'Container' Zipcode = '' -- Your zipcode eg '1234AB' Housenr = '' -- Your housnr. eg '99' Housenrsuf = '' -- Your housnr suffix ('a', 'b' etc) Hostname = '' -- m_opzet & m_opzet_api: Specify the hostname of your website. eg 'inzamelkalender.hvcgroep.nl' Street = '' -- Street name Only needed for: m_recycleapp BPName = '' -- Burgerportaal name either: 'assen'/'bar'/'rmn' Companycode = '' -- m_ximmio Companycode. (See m_ximmio.lua file for how to find this code).
Required information per module: (R=Required/O=Optional)
Module Zipcode Housenr Housenrsuf Hostname Street BPName Companycode** m_burgerportaal R R O R m_deafvalapp R R O m_mijnafvalwijzer R R O O m_Montferland R R O m_omrin R R O m_opzet R R O R m_opzet_api R R O R m_recycleapp-be R R O R m_rova_api R R O m_ximmio R R O R m_zuidlimburg R R O -
choose one of these modules by removing the "--" in front of the modulename. eg for "mijnafvalwijzer":
--websitemodule = "m_deafvalapp" websitemodule = "m_mijnafvalwijzer" --websitemodule = "m_mijnafvalwijzer_api" --websitemodule = "m_montferland" --websitemodule = "m_recycleapp" --websitemodule = "m_omrin" --websitemodule = "m_opzet" --websitemodule = "m_opzet_api" --websitemodule = "m_recycleapp-be" --websitemodule = "m_rova_api" --websitemodule = "m_ximmio" --websitemodule = "m_zuidlimburg" ----Special module read heading in the file for details --websitemodule = "m_csv_file"
-
Specify the appropriate directories (Raspberry Pi example):
-- Specify the directoy used for the Data and Log files. -- It will default to the gabagecalendar/data directory when invalid or missing. --datafilepath = '/var/tmp'
In case you run Domoticz in Docker you could simply leave datafilepath empty!
This will trigger the Data and logfiles to be stored in: /opt/domoticz/config/scripts/lua/garbagecalendar/data -
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:
13:45:00 MainScript: #!# -- start -- Add these records into the garbagetype_cfg table and adapt the schedule and text info to your needs : ["green"] ={hour=19,min=02,daysbefore=1,reminder=0,text="green",icon=""}, ["paper"] ={hour=19,min=02,daysbefore=1,reminder=0,text="paper",icon=""}, ["grey"] ={hour=19,min=02,daysbefore=1,reminder=0,text="grey",icon=""}, 13:45:00 MainScript: #!# -- end ----------------------------
So you simply copy and paste those (3) lines from the log into the below section of "garbagecalendarconfig.lua" and update the text field to de description you like to see in the Domoticz text device and the hour & min fields to the time you like to get a notification:
-- Look at the Domoticz log for any missing records as they will be displayed there and can be just copy/pasted in. -- Fields description: -- hour & min ==> the time the check needs to be performed and notification send when daysbefore is true -- daysbefore ==> 0 means that the notification is send on the day of the planned garbage collection -- daysbefore ==> X means that the notification is send X day(s) before the day of the planned garbage collection -- reminder ==> Will send a second reminder after x hours. 0=no reminder (can be between 0 - 24 hours) -- text ==> define the text for the notification and Text Device. -- icon ==> (optional) define the icon to use for the text device in Domoticz -- active ==> (optional) default="on" -- active="on" Both will show in Domoticz Text Device and Send notifications -- active="off" Will show in Domoticz Text Device but not send notifications -- active="skip" Will not show in Domoticz Text Device and not send notifications -- The "reloaddata" entry is required to run the background process to update the data one time per day. -- The "dummy" entry can be used to force reading the data, update the Domoticz text device and see if there are any errors or missing garbadge types. garbagetype_cfg = { -- Add any missing records below this line ["green"] ={hour=19,min=02,daysbefore=1,reminder=3,text="Groene bak",icon="garbagecalendar_green"}, ["paper"] ={hour=19,min=02,daysbefore=1,reminder=3,text="Papier",icon="garbagecalendar_blue"}, ["grey"] ={hour=19,min=02,daysbefore=1,reminder=3,text="Restafval",icon="garbagecalendar_grey"}, -- Add any missing records above this line -- "reloaddata" is used to start the background update process at this given time. ["reloaddata"] ={hour=02,min=30,daysbefore=0,reminder=0,text="trigger for reloading data from website into garbagecalendar_modulesname.data"}, ["dummy1"] ={hour=02,min=30,daysbefore=0,reminder=0,text="dummy to trigger testing"}}
The icon="" field is either empty or needs to contain the name of one of the already existing Domoticz Custom Icons or one of the available icon.zip files in the icons directory. You can add your own prefered icons there too and use that name in icon= config field. Garbage_calendar will look in the "garbagecalendar/icons" directory for any missing icons and try to upload it into Domoticz when available. The text device icon will be set to the default (0) when there is no icon defined or the defined Icon isn't available in Domoticz.
Update the Configuration section for the Notification system in case you like to get warned at the defined times in "garbagetype_cfg":
NotificationEmailAdress = {'',''} -- Specify multiple Email Addresses for the notifications. Leave empty to skip email notification Notificationsystem = '' -- Specify notification system eg "telegram/pushover/gcm/http/kodi/lms/nma/prowl/pushalot/pushbullet/pushsafer" leave empty to skip Notificationscript = '' -- Specify personal notification script/command eg: lua sendmessage.lua "@TEXT@" (where @TEXT@ will be replaced by the notification text.) EventNotificationscript = '' -- Script to run in the Domoticz event system when a notificate occurs. See example "notification_event_script.lua" -- It also supports: @GARBAGETYPE@; @GARBAGEDATE@; @GARBAGETEXT@ -- Define how the title and bodytext should look -- @DAY@ ==> Will be replaced by notificationtoday; notificationtomorrow; notificationlonger depending on the days difference. -- @GARBAGETYPE@ ==> Will be replaced by the GarbageType definition from the WebSite -- @GARBAGEDATE@ ==> Will be replaced by the pickup date found on the schedule data -- @GARBAGETEXT@ ==> Will be replaced by the text from garbagetype_cfg[].text field -- @REMINDER@ ==> Will be set to "" for first notification and "notificationreminder" for the reminder run -- @TEXT@ ==> Will be replaced by the finalised notificationtext and can be used in the notification script -- @TITLE@ ==> Will be replaced by the finalised notificationtitle and can be used in the notification script --### Dutch example notificationreminder = 'herinnering' notificationtitle = 'GarbageCalendar: @DAY@ de @GARBAGETEXT@ aan de weg zetten!' notificationtext = '@GARBAGETEXT@ wordt @DAY@ opgehaald! (@REMINDER@)' notificationtoday = 'vandaag' notificationtomorrow = 'morgen' notificationlonger = 'over @DAYS@ dagen' notificationdate = 'wd dd mmmm yyyy' -- @GARBAGEDATE@ format -> Options are the same as available for textformat date options --### English example --~ notificationtitle = 'GarbageCalendar: @GARBAGETEXT@ will be picked up in @DAY@!' --~ notificationtext = 'Put the @GARBAGETEXT@ out as it will be picked up @DAY@.!' --~ notificationtoday = 'today' --~ notificationtomorrow = 'tomorrow' --~ notificationlonger = 'in @DAYS@ days' --~ notificationdate = 'wd dd mmmm yyyy' -- Options are the same as available for textformat date options
-
Optionally updated the default text format for the Domoticz text device in this section::
-- ### define format for text device -- date options: -- wd = weekday in 3 characters as defined in the daysoftheweek table below. eg Zon;Maa;Din -- wdd = weekday as defined in the Longdaysoftheweek table below. eg zondag;maandag;dinsdag -- dd = day in 2 digits eg 31 -- mm = month in 2 digits eg 01 -- mmm = month abbreviation in 3 characters as defined in the ShortMonth table below. eg : jan -- mmmm = month as defined in the LongMonth table below. eg: januari -- yy = year in 2 digits eg 19 -- yyyy = year in 4 digits eg 2019 -- Garbage type description options -- sdesc = short garbage type description from Website eg pmd -- ldesc = long garbage type description from Website when available, will be replaced by table description when not -- tdesc = Use the description available in the table text field textformat = "wd dd mmm - tdesc" -- -- the tdevformat variable can contain the surrounding text device formatting for the total textbox information -- # => Generated lines that need to be surrounded. This variable is ignored when it doesn't contain a # character. -- e.g.: tdevformat = '<div style="font-size : 8px" align="center">#</div> tdevformat = '' -- no formatting
-
Optionally Define/update the weekday, short abbreviation to be shown in the text device. see previous topic:
-- Date/day info: daysoftheweek={"zon","maa","din","woe","don","vri","zat"} Longdaysoftheweek={"zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"} ShortMonth={"jan","feb","maa","apr","mei","jun","jul","aug","sep","okt","nov","dec"} LongMonth={"januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"}
-
Optionally define whether you like to see the upcoming event including duplicate garbage types or the next x events of unique garbage type events:
-- ### define what to show in the Domoticz text device -- false => show multiple occurrences of a garbagetype -- true => show one the next occurrence for a unique garbagetype ShowSinglePerType = false
example result difference for ShowSinglePerType with these upcoming events:
Grijze bak - 14-02-2020 Groene bak - 21-02-2020 Grijze bak - 28-02-2020 Blauwe bak - 29-02-2020
ShowSinglePerType = false
ShowSinglePerType = true
-
Optionally enable the generation of an ics calendar file:
-- Configuration for the generation of an ics file: -- IcalDesc: -- @GARBAGETYPE@ ==> Will be replaced by the GarbageType definion from the WebSite -- @GARBAGETEXT@ ==> Will be replaced by the text from garbagetype_cfg[].text field IcalEnable = false -- false/true: When true, a garbagecalendar_Modulename.ics will be created in the datafilepath which can be used in a calendar application. IcalTitle = "GarbageCalendar" -- title of the calendar IcalDesc = "@GARBAGETEXT@ wordt opgehaald." -- text for the events in the calendar IcalEvents = 10 -- max number of upcomming events to save to icalfile, but could be less when less events are provided by the website. IcalNotify = 12 -- Notification Time in hours before event. 0=no notification
-
-
You should be ready to go now. Ensure you reset the mydebug to:
-- run the script as it normally does when any of the scheduled times is the current time
mydebug = false -- run the web update module in the foreground with each run for debugging.
testdataload = false
-- run the web update module in the background with each run for debugging. (testdataload takes precedent)
testdataloadbatch = false
-- trigger a test notification each run for the first record for testing the notification system. testnotification = falseto avoid a lot of messages in the Domoticz log. check the testing page in case you need to test/debug your installation.
More information can be found or questions can asked here: https://forum.domoticz.com/viewtopic.php?t=31295