first commit

This commit is contained in:
Souti
2025-03-06 11:09:58 +01:00
commit 11f7d440ff
330 changed files with 38306 additions and 0 deletions

95
lua/old/script_time_livebox.old Executable file
View File

@@ -0,0 +1,95 @@
---------------------------------
-- Script de détection de présence via livebox
-- Auteur : Sopalin
-- Date : 22 Juillet 2016
-- Nécessite un switch classique
-- source :
---------------------------------
require "scripts/lua/functions"
--recupere les minutes
time=os.time()
seconds=tonumber(os.date('%S',time))
minutes=tonumber(os.date('%M',time))
commandArray={}
function testActive(name, active)
if active then
--commandArray[name]='On'
switchIfNeeded(name, 'On')
else
switchIfNeeded(name, 'Off')
--commandArray[name]='Off'
end
debug("### Test active Name : "..name.." active "..tostring(active))
end
--time = os.date("*t")
if (minutes % 10 == 7) then
--import des fontions pour lire le JSON
json = (loadfile "/opt/domoticz/scripts/lua/JSON.lua")()
--Récupération des informations sur la livebox
--Utilisation d'un script VBS sous windows
--Utilisation d'un script bash pour extraire les données
----------------------------------------------------------------
--Lecture des données
local f = assert(io.open("/tmp/getHosts.txt","r"))
local livebox = f:read('*all')
f:close()
--Décodage ud fichier
local jsonLivebox = json:decode(livebox)
--debug("DEBUG")
--debug(timedifference(otherdevices_lastupdate['Presence Thomas']))
--commandArray['Theo']='Off'
--commandArray['Moi']='Off'
--commandArray['Manon']='Off'
devices = jsonLivebox['result']['status']
--Parcours du fichier pour vérifier la présence d'un téléphone
for result,status in pairs(devices) do
local name = status['hostName']
debug("Name : "..name.." IP : "..status['ipAddress'].." "..tostring(status['active']))
if (name == "Windows-Phone" or name == "Akhesa" or name == "Playstation3") then
--commandArray['Theo']='On'
testActive('Theo', status['active'])
end
if (name == "iPhone-de-Jerome") then
--commandArray['moi']='On'
testActive("Moi", status['active'])
end
if (name == "Akhenaton-1" or name == "Akhenaton") then
testActive("Akhenaton", status['active'])
end
if (name == "Manon" or name == "AcerManon") then
--commandArray['Manon']='On'
testActive("Manon", status['active'])
end
if (name == "TeleChambre" or name == "AcerManon"
or name == "Volumio" or name == "LibreELEC" or name == "Akhesa"
or name == "SoutiHP" or name == "Hackintosh"
or name == "Akhenaton"
or name == "Domi" or name == "DomiPro" or name == "Octoprint"
or name == "Recovery" or name == "orangepizero" or name == "orangepizero-1") then
testActive(name, status['active'])
end
if (name == "RadiateurManon" or name == "RadiateurTheo" or name == "RadiateurBureau"
or name == "RadiateurChambre") then
if status['active'] then
-- nothing
else
-- commandArray['SendNotification']='Alerte radiateur '..name..'#Alerte radiateur ne repond pas au ping '..name
end
end
end
end
return commandArray