sur domoticz pour un signe donné et de nous alerter le cas échéant selon le niveau de notification choisi
Code : Tout sélectionner
--[[
name : script_time_horoscope.lua
auteur : papoo
version : 1.10
Mise à jour : 27/06/2016 Changement de site
date : 26/06/2016
Principe :
Ce script a pour but de remonter les informations du site http://mon.astrocenter.fr/ dans un device texte
sur domoticz pour un signe donné et de nous alerter le cas écheant selon le niveau de notification choisi
]]--
-- ========================================================================
-- Variables à éditer
-- ========================================================================
local signe = "cancer" --[[ renseigner le signe choisi en minuscule sans accent : belier, taureau, gemeaux, cancer, lion, vierge,
balance, scorpion, sagittaire, capricorne, verseau, poissons ]]--
local dz_horoscope_text = 719 -- renseigner l'id du device texte associé (dummy - text)
local send_notification = 0 -- 0: notifications désactivées, 1: notifications actives
local debugging = false -- true pour voir les logs dans la console log Dz ou false pour ne pas les voir
-- ========================================================================
-- Fin Variables à éditer
-- ========================================================================
local indexArray=0
-- ========================================================================
-- Fonctions
-- ========================================================================
function voir_les_logs (s)
if (debugging) then
print ("<font color='#f3031d'>".. s .."</font>");
end
end
-- ========================================================================
-- Fin Fonctions
-- ========================================================================
commandArray = {}
time = os.date("*t")
--if (time.hour == 00 and time.min == 20) then -- tout les matins à 00h20
if (time.min == 20 and ((time.hour == 7) or (time.hour == 13) or (time.hour == 18))) then -- 3 éxecutions du script par jour à 7H20, 13h20 et 18H20
-- if time.hour % 2 == 0 then -- toutes les deux heures
-- if (time.hour%1 == 0 and time.min == 10) then -- Toutes les heures et 10 minutes
-- if time.min % 2 == 0 then
print('script_time_horoscope.lua')
local fname ="horoscope.xml"
os.execute("wget -q -O " .. fname .. " http://mon.astrocenter.fr/horoscope/quotidien/"..signe)
local f = io.open(fname, "r")
if f == nil then
print("Error opening file '" .. fname .. "'.")
os.exit(1)
end
local testHtml = f:read("*all")
f:close()
--print_r(testHtml)
for instance in testHtml:gmatch("<body>(.-)</body>") do
div, horoscope=instance:match('horoscope du jour(.-)<p>(.-)</p>')
end
if horoscope ~= nil and signe ~= nil then
voir_les_logs("--- --- --- Horoscope pour le signe du ".. div,debugging)
voir_les_logs("--- --- --- ".. signe .." : ".. horoscope,debugging)
commandArray[indexArray] = {['UpdateDevice'] = dz_horoscope_text..'|0|'.. horoscope}
indexArray=indexArray+1
if send_notification > 0 then
commandArray[indexArray] = {['SendNotification'] = 'horoscope pour le signe du '.. signe ..'#'.. horoscope}
indexArray=indexArray+1
end
end
end -- if time
return commandArray
sur domoticz pour un signe donné et de nous alerter le cas échéant selon le niveau de notification choisi
Code : Tout sélectionner
--[[
name : script_time_horoscope.lua
auteur : papoo
version : 1.00
date : 26/06/2016
Principe :
Ce script a pour but de remonter les informations du site http://www.horoscope-gratuit.org/ dans un device texte
sur domoticz pour un signe donné et de nous alerter le cas écheant selon le niveau de notification choisi
]]--
-- ========================================================================
-- Variables à éditer
-- ========================================================================
local signe = "cancer" --[[ renseigner le signe choisi en minuscule sans accent : belier, taureau, gemeaux, cancer, lion, vierge,
balance, scorpion, sagittaire, capricorne, verseau, poissons ]]--
local dz_horoscope_text = 719 -- renseigner l'id du device texte associé (dummy - text)
local send_notification = 0 -- 0: notifications désactivées, 1: notifications actives
local debugging = false -- true pour voir les logs dans la console log Dz ou false pour ne pas les voir
-- ========================================================================
-- Fin Variables à éditer
-- ========================================================================
local indexArray=0
-- ========================================================================
-- Fonctions
-- ========================================================================
function voir_les_logs (s)
if (debugging) then
print ("<font color='#f3031d'>".. s .."</font>");
end
end
-- ========================================================================
-- Fin Fonctions
-- ========================================================================
commandArray = {}
time = os.date("*t")
if (time.hour == 00 and time.min == 20) then -- tout les matins à 00h20
-- if (time.min == 20 and ((time.hour == 7) or (time.hour == 13) or (time.hour == 18))) then -- 3 éxecutions du script par jour à 7H20, 13h20 et 18H20
-- if time.hour % 2 == 0 then -- toutes les deux heures
-- if (time.hour%1 == 0 and time.min == 10) then -- Toutes les heures et 10 minutes
-- if time.min % 2 == 0 then
print('script_time_horoscope.lua')
local fname ="horoscope.xml"
os.execute("wget -q -O " .. fname .. " http://www.horoscope-gratuit.org/horoscope-" ..signe..".php")
local f = io.open(fname, "r")
if f == nil then
print("Error opening file '" .. fname .. "'.")
os.exit(1)
end
local testHtml = f:read("*all")
f:close()
for instance in testHtml:gmatch("<BODY>(.-)</BODY>") do
div, horoscope=instance:match('<strong>Horoscope(.-)</strong><br /><br />(.-)</div>')
end
if horoscope ~= nil and signe ~= nil then
voir_les_logs("--- --- --- Horoscope pour le signe du ".. div,debugging)
voir_les_logs("--- --- --- ".. signe .." : ".. horoscope,debugging)
commandArray[indexArray] = {['UpdateDevice'] = dz_horoscope_text..'|0|'.. horoscope}
indexArray=indexArray+1
if send_notification > 0 then
commandArray[indexArray] = {['SendNotification'] = 'horoscope pour le signe du '.. signe ..'#'.. horoscope}
indexArray=indexArray+1
end
end
end -- if time
return commandArray