Files
Domoticz/lua/old/script_time_livebox.old
2025-03-06 11:09:58 +01:00

96 lines
3.0 KiB
Plaintext
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---------------------------------
-- 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