Blame | Last modification | View Log | Download
# SetupJos edited this page on 14 Mar 2021 ยท [37 revisions](https://github.com/jvanderzande/GarbageCalendar/wiki/Setup/_history)##### Clone this wiki locallyhttps://github.com/jvanderzande/GarbageCalendar.wiki.git## Prerequisites- ***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***## Setup- ### DomoticzIn the hardware section of Domoticz; create Dummy and within the Dummy create a virtual Text sensor and remember the name you gave this virtual Text sensor. eg "Container".- ### Install scripts[Download](https://github.com/jvanderzande/GarbageCalendar/archive/master.zip) the main script **"script\_time\_garbagecalendar.lua"** and the directory **"garbagecalendar"** , including all the files in it, and store them in the **"domoticz/scripts/lua"** directory.- ### Create personal configGo into directory **"garbagecalendar/"** and copy file **"garbagecalendarconfig_model.lua"** to **"garbagecalendarconfig.lua"**. This will be the file that contains your personal setup and preferences, which will make it easy in the future to upgrade the scripts from Github without loosing your personal configuration settings.### Update personal configEdit the following information in file **"garbagecalendarconfig.lua"**:- #### Domoticz & Address information:```myGarbageDevice = '' -- The Text devicename in Domoticz. eg 'Container'ShowNextEvents = 3 -- indicate the next x events to show in the TEXT Sensor in DomoticzZipcode = '' -- 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'-- *m_ximmio: Specify the companycode. (See m_ximmio.lua on how to find this code).Street='' -- Street name Only needed for: m_recycleapp```**Required information per module:** (R=Required/O=Optional)| Module | Zipcode | Housenr | Housenrsuf | Hostname | Street || ----------------- | ------- | ------- | ---------- | -------- | ------ || m_deafvalapp | R | R | O | | || m_Goeree | R | R | O | | || m_mijnafvalwijzer | R | R | O | | || m_Montferland | R | R | O | | || m_recycleapp | R | R | O | | R || m_omrin | R | R | O | | || m_opzet | R | R | O | R | || m\_opzet\_api | R | R | O | R | || m\_rova\_api | R | R | O | | || m_Westland | R | R | O | | || m_ximmio | R | R | O | R* | || m_zuidlimburg | R | R | O | | |1. #### Moduleschoose one of these modules by removing the "--" in front of the modulename. eg for "mijnafvalwijzer":```--websitemodule = "m_deafvalapp"--websitemodule = "m_goeree-overflakkee"websitemodule = "m_mijnafvalwijzer"--websitemodule = "m_montferland"--websitemodule = "m_recycleapp"--websitemodule = "m_omrin"--websitemodule = "m_opzet"--websitemodule = "m_opzet_api"--websitemodule = "m_rova_api"--websitemodule = "m_westland"--websitemodule = "m_ximmio"--websitemodule = "m_zuidlimburg"----Special module read heading in the file for details--websitemodule = "m_csv_file"```- #### directories to usedSpecify the appropriate directories (Raspberry Pi example):```datafilepath = '/var/tmp' -- specify the directory where the garbagecalendar_modulesname.data & garbagecalendar.log will be storedscriptpath = '/home/pi/domoticz/scripts/lua' -- specify the directory for the main "script_time_garbagecalendar.lua" scriptdomoticzjsonpath = '/home/pi/domoticz/scripts/lua' -- specify the path to Domoticz where the JSON.lua file can be found```- #### Notifications and devicetextTo 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="Groene bak"},["paper"] ={hour=19,min=02,daysbefore=1,reminder=0,text="Papier"},["grey"] ={hour=19,min=02,daysbefore=1,reminder=0,text="Restafval"},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.-- 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["pmd"] ={hour=19,min=02,daysbefore=1,reminder=0,text="pmd"},["gft"] ={hour=19,min=02,daysbefore=1,reminder=0,text="gft"},["papier"] ={hour=19,min=02,daysbefore=1,reminder=0,text="papier"},-- 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"}}```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 notificationNotificationsystem = '' -- Specify notification system eg "telegram/pushover/gcm/http/kodi/lms/nma/prowl/pushalot/pushbullet/pushsafer" leave empty to skipNotificationscript = '' -- Specify personal notification script/command eg: lua sendmessage.lua "@TEXT@" (where @TEXT@ will be replaced by the notification text.)-- Define how the title and bodytext should look-- @DAY@ ==> Will be replaced by notificationtoday; notificationtomorrow; notificationlonger depending on the days difference. (those are defined below)-- @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--### Dutch examplenotificationtitle = 'GarbageCalendar: @DAY@ de @GARBAGETEXT@ aan de weg zetten!'notificationtext = '@GARBAGETEXT@ wordt @DAY@ opgehaald!'notificationtoday = 'vandaag'notificationtomorrow = 'morgen'notificationlonger = 'over @DAYS@ dagen'notificationdate = 'dd mmm yyyy' -- @GARBAGEDATE@ format -> Options are the same as available for textformat date options```- #### Format text for Domoticz deviceOptionally 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 fieldtextformat = "wd dd mmm - tdesc"```- #### Standard conversion tablesOptionally 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"}```- #### upcoming events to shownOptionally 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 garbagetypeShowSinglePerType = false```example result difference for ***ShowSinglePerType*** with these upcoming events:```Grijze bak - 14-02-2020Groene bak - 21-02-2020Grijze bak - 28-02-2020Blauwe bak - 29-02-2020```***ShowSinglePerType = false******ShowSinglePerType = true***- 1. #### Generate ICS fileOptionally 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 fieldIcalEnable = 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 calendarIcalDesc = "@GARBAGETEXT@ wordt opgehaald." -- text for the events in the calendarIcalEvents = 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```### We're doneYou should be ready to go now. Ensure you reset the mydebug to:**"mydebug = false -- (true/false)"**to avoid a lot of messages in the Domoticz log. check the [testing](https://github.com/jvanderzande/GarbageCalendar/wiki/testing) page in case you need to test/debug your installation.