DzVents : Obtenir des informations sur les jours fériés du site

kayaposoft a publié un logiciel open-source sous licence MIT Enrico Service.

Vous pouvez donc l’étudier, y contribuer, le modifier ou l’utiliser. (donc si votre pays n’est pas encore supporté, vous pouvez ajouter le XML requis pour l’obtenir dans la liste).
Pour l’instant seuls les jours fériés sont disponibles pour la France, esperons que les vacances scolaires seront bientôt implémentées.

Waaren du forum domoticz vient de créer un script dzVents qui utilise les nouvelles options. Le script utilise les données persistantes de dzVents pour stocker les résultats de kayaposoft.
En utilisant ce mécanisme, ce script n’aura à visiter ce site que tous les deux mois.

J’y ai apporté le support des dates (jours et mois) en Français ainsi que la traduction de quelques messages
le script complet

--[[ getHolidays.lua for [ dzVents >= 2.4 ]

Start with creating a string type uservariable in domoticz (SETUP] ==>> [MORE OPTIONS] ==>> [uservariableS] ==>> [ADD] and put the name in the appropriate place between the lines starting with --++++
Next is to decide how you want the result of the check if today is a public holiday to be presented. The just created uservariable will contain the localized datestring with either the public holiday name or the userDefined_noPublicHoliday text.
Further options are:
- an integer typed uservariable:  if today is a public holiday it will be set to 1; if not it will be set to 0
- a text device: it will be set to the same text as set in the uservariable
- an alert device: as text device plus alert level 5 if today is a public holiday or
                                       alert level 2 if today is Saturday or
                                       alert level 3 if today is Sunday  or alert level 1 all other days
- a switch: On if today is a public holiday / Off if not

For one or more of these options to take effect the variable or (virtual)device must be defined in domoticz and either the name or idx must entered in the Optional section of the area surrounded by the lines starting with --++++

You can trigger the script for an initial run or for testing by updating the string type uservariable defined at the beginning.

this script collect public holiday information from Enrico Service 2.0
This is open-source software licensed under the MIT License so you can study, contribute, change or use it. (so if your country is not supported yet you could add the required XML to get it in the list)
See Enrico source code on

Supported countries in as of 22 July 2018:

Angola, Australia, Austria, Belgium, Bosnia and Herzegovina, Brazil, Canada, China, Colombia, Czech Republic, Germany, Denmark, Estonia, Finland, France, United Kingdom, Greece, Hong Kong, Croatia, Hungary, Isle of Man, Ireland, Iceland, Israel, Italy, Japan, Korea (South), Lithuania, Luxembourg, Latvia, Mexico, Macedonia, Netherlands, Norway, New Zealand, Poland, Portugal, Romania, Russian Federation, Singapore, Serbia, Slovakia, Slovenia, Sweden, Ukraine, United States of America, South Africa

(get an up to date list at )

 Script collects information for at least one year ahead and stores this in dzVents persistent data. The collection process is not done frequently as this data is kind of static. The default period between calls to kayaposoft is set to 60 days.


--++++--------------------- Mandatory: Set your values and device names below this Line --------------------------------------
local userDefined_httpResponse      = "getHolidays_Response"    -- This will trigger the script after the return
local userDefined_stringVariable    = "Vacances"                 -- Name of your uservariable created as type string (mandatory)
local userDefined_noPublicHoliday   = "n'est pas un jour férié"        -- Localized text for no public holiday
local userDefined_country           = "FRA"                      -- Also used for language
local userDefined_region            = "A"                        -- mandatory if regions are defined for your country
-- find list of valid regions at

----------------------------------------- Optional: presenting the result ----------------------------------------------------
--local userDefined_integerVariable   = "HolidayInteger"    -- Name of your uservariable if you created it as type integer or set to line to comment
--local userDefined_textDevice        = "HolidayText"       -- Name with quotes or idx without when created as virtual text device or set to line to comment
--local userDefined_alertDevice       = "HolidayAlert"      -- Name with quotes or idx without when created as virtual alert device or set to line to comment
--local userDefined_switchDevice      = 995                 -- Name with quotes or idx without when created as virtual switch or set to line to comment

--++++---------------------------- Set your values and device names above this Line --------------------------------------------

function date_en_francais(str)
    if (str) then
	str = string.gsub(str, "January", "Janvier;");
	str = string.gsub(str, "February",	"Février")
	str = string.gsub(str, "March",	"Mars")
	str = string.gsub(str, "April",	"Avril")
	str = string.gsub(str, "May",	"Mai")
	str = string.gsub(str, "June",	"Juin")
	str = string.gsub(str, "July",	"Juillet")
	str = string.gsub(str, "August",	"Août")
	str = string.gsub(str, "september",	"Septembre")
	str = string.gsub(str, "October",	"Octobre")
	str = string.gsub(str, "November",	"Novembre")
	str = string.gsub(str, "December",	"Décembre")
	str = string.gsub(str, "Monday",	"Lundi")
	str = string.gsub(str, "Tuesday",	"Mardi")
	str = string.gsub(str, "Wednesday",	"Mercredi")
	str = string.gsub(str, "Thursday", "Jeudi")
    str = string.gsub(str, "Friday", "Vendredi")
    str = string.gsub(str, "Saturday", "Samedi")
    str = string.gsub(str, "Sunday", "Dimanche")
    return (str)

return {
    on      =   {   timer           =   { "at 00:01","at 06:03" },               -- daily run (One extra for redundancy)
                    variables       =   { userDefined_stringVariable },
                    httpResponses   =   { userDefined_httpResponse }               -- Trigger the handle Json part
    logging =   {   level           =   domoticz.LOG_ERROR,
                    marker          =   "getHolidays"
    data    =   {   holidays              = {initial = {} },                     -- Store holidaysTable in dzVents persistent data
                    refreshDate           = {initial = "" },
                    country               = {initial = userDefined_country },
                    region                = {initial = userDefined_region },

    execute = function(dz, triggerObject)
        -- Compose URL and send 
        local function getHolidays(secondsFromNow)
            secondsFromNow = secondsFromNow or 1                   -- catch empty parm
            local yearsAhead         = 1 * 366 * 24 * 3600
            local getHolidays_url  = "" ..
                                    "&fromDate=" .."%d-%m-%Y")  ..                              -- today
                                    "&toDate=".."%d-%m-%Y",os.time() + yearsAhead ) ..      -- today + yearsAhead years
                                    "&country=" .. userDefined_country ..
                                    "®ion=" .. userDefined_region ..

            dz.openURL  ({
                            url = getHolidays_url ,
                            method = "GET",
                            callback = userDefined_httpResponse,

        -- walk trough the table to find today's date    
        local function processHolidays()
            local holidayTable  =
            local today         ="*t")

            for i = 1,#holidayTable do
                if holidayTable[i] == and holidayTable[i].date.month == today.month and holidayTable[i].date.year == today.year then
                   return holidayTable[i].name[1].text                            -- holiday found
            return userDefined_noPublicHoliday

        -- update variables and devices
        local function setDomoticzDevices(holidayName)
            local fullText  = date_en_francais(" %A %d %B, %Y")):gsub(" 0"," ") .. ": " ..  holidayName


            if userDefined_integerVariable then
                if holidayName ~= userDefined_noPublicHoliday then

            if userDefined_textDevice then

            if userDefined_alertDevice then
                alertTable = {dz.ALERTLEVEL_YELLOW,        -- Sunday
                              dz.ALERTLEVEL_GREEN,         -- Monday
                              dz.ALERTLEVEL_GREEN,         -- Tuesday
                              dz.ALERTLEVEL_GREEN,         -- Wednesday
                              dz.ALERTLEVEL_GREEN,         -- Thursday
                              dz.ALERTLEVEL_GREEN,         -- Fridayday
                              dz.ALERTLEVEL_ORANGE,         -- Saturday
                              dz.ALERTLEVEL_RED            -- Holiday
                if holidayName == userDefined_noPublicHoliday then
                    dz.devices(userDefined_alertDevice).updateAlertSensor(alertTable["*t").wday], fullText)
                    dz.devices(userDefined_alertDevice).updateAlertSensor(alertTable[#alertTable], fullText)

            if userDefined_switchDevice then
                if holidayName ~= userDefined_noPublicHoliday then

        -- set number of days since last refresh 
        local function daysSinceLastRefresh()
            local lastRefreshDate
            if ~= "" then
                lastRefreshDate =   -- was set in earlier run
                lastRefreshDate ="*t",1)        -- use very old date because is not yet set
            return os.difftime(os.time(), os.time(lastRefreshDate)) / (3600*24)
        -- Add entry to log and notify to all subsystems
        local function errorMessage(message)
        -- Store table and date in persistent data 
        local function updatePersistentData()
            if #triggerObject.json > 0 then
          = triggerObject.json           -- fill with the complete httpResponse
       ='*t')         -- set refreshDate to current datetime
                return true
                return false
        -- Do we need to get fresh data ? 
        local function freshData()
            local daysBetweenRefresh = 60
            return[1] ~= nil  and
                     daysSinceLastRefresh() < daysBetweenRefresh and
                     userDefined_country == and
                     userDefined_region  ==
        -- Main 
        if triggerObject.isHTTPResponse then
            if triggerObject.ok then
                if updatePersistentData() then
                    errorMessage("Problème avec les données dans la réponse Enricp (les données semblent manquer)")   -- Forgot to enter valid country / region ?
                errorMessage("Problème avec la réponse Enrico  (pas ok)")
                getHolidays(600)                            -- response not OK, try again after 10 minutes
            if freshData() then
            else                                            -- does not contain any data or data needs to be refreshed

retrouver la dernière version de ce script sur

 Site Officiel :

Laisser un commentaire