Quote of the Day Module
Posted: Thursday 19 October 2017 16:25
Willing to add some ironic behavior to my notification and as a Murphy's Law fellow, I've created a quote of the day module that can be used wherever you want...
It is extremely simple!
It's made by a file with a simple phrases db and random generated quote and your script where to put it....
the module contains the follow:
save the file and copy to domoticz/scripts/lua/ folder and name it quote.lua
into your script use the following to include and use the quote (can be used in dzVents framework also):
that's all....
ciao
M
It is extremely simple!
It's made by a file with a simple phrases db and random generated quote and your script where to put it....
the module contains the follow:
Code: Select all
local quote = {};
function quote.getQuote()
local quotes = {
"\nAnything that can go wrong will go wrong ",
"\nIf there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it",
"\nLeft to themselves, things tend to go from bad to worse.",
"\nIt is impossible to make anything foolproof because fools are so ingenious",
"Add any other quote and save the file, you do not need to change any other line in the code"
}
local strQuote = ''
strQuote = quotes[math.random(1,#quotes)]
return strQuote
end
return quote
into your script use the following to include and use the quote (can be used in dzVents framework also):
Code: Select all
package.path = package.path .. ';' .. '/home/pi/domoticz/scripts/lua/?.lua'
local quote = require("quote")
print(quote.getQuote())
ciao
M