Bonjour,
je voudrais automatiser le rétro éclairage (bande LED) qui est derrière ma TV en fonction de son allumage/extinction.
J'ai donc regardé au niveau du "System Alive Checker (Ping)" que j'utilise pour vérifier mon Pi zéro mais malheureusement la TV ne répond pas au ping "classique". J'ai essayé avec windows et pareil, aucune réponse.
J'ai donc regardé le fonctionnement de l'appli Fing qui la détecte et je suis tombé sur la commande arping sous linux. Avec cette commande le ping fonctionne. Est-il possible de modifier le "System Alive Checker (Ping)" en Arping ? Ou faut-il passer par un script pour le faire et comment récupérer le retour du arping pour renseigner un interrupteur ?
Merci d'avance !
System Alive Checker (Ping) et TV sharp
System Alive Checker (Ping) et TV sharp
Dz version : 2024.7
Rpi 4 avec dongle téléinfo, GPIO pour le moment !
Rpi 4 avec dongle téléinfo, GPIO pour le moment !
Re: System Alive Checker (Ping) et TV sharp
Bonjour Higgings,
Essaye mon script de présence :
https://easydomoticz.com/forum/viewtopi ... =17&t=7176
La présence est testée via arp et ping.
Sinon, il reste aussi possible de récupérer l'info via la box internet.
Essaye mon script de présence :
https://easydomoticz.com/forum/viewtopi ... =17&t=7176
La présence est testée via arp et ping.
Sinon, il reste aussi possible de récupérer l'info via la box internet.
Re: System Alive Checker (Ping) et TV sharp
Merci pour ta réponse, je viens de tester (je n'ai pas la "bonne" version de Dz v3.8153). J'ai une erreur :
la ligne 44 correspond dans mon script à:
et il y a bien le arp dans le dossier...
le script modifié pour mon utilisation:
y a-t-il des dépendances à installer, j'ai installé le arping hier et il fonctionne.
Merci pour ton aide
Code : Tout sélectionner
2018-11-18 13:35:00.358 dzVents: Info: ARPing 1.0: ------ Start external script: ARPing.lua:, trigger: every 1 minutes
2018-11-18 13:35:00.358 Error: dzVents: Error: ARPing 1.0: An error occured when calling event handler ARPing
2018-11-18 13:35:00.358 Error: dzVents: Error: ARPing 1.0: /home/pi/domoticz/scripts/dzVents/scripts/ARPing.lua:44: attempt to index field 'utils' (a nil value)
2018-11-18 13:35:00.358 dzVents: Info: ARPing 1.0: ------ Finished ARPing.lua Code : Tout sélectionner
if (domoticz.utils.fileExists("/proc/net/arp"))thenle script modifié pour mon utilisation:
Code : Tout sélectionner
--[[
Prerequisits
==================================
Domoticz v3.8837 or later (dzVents version 2.4 or later)
Scan ARP + ping
-- Authors ----------------------------------------------------------------
V1.0 - Neutrino
]]--
-- Variables to customize --------------------------------------------------
local fetchIntervalMins = 1 -- Délais entre interrogations
-- Tableau des périphériques à interroger
--ping['adresse IP']={'Interrupteur virtuel',0}
local ping = {}
ping['192.168.192.81']={'TV',0}
ping['192.168.192.71']={'Wemos_cuve',0}
ping['192.168.192.29']={'Dlink_portillion',0}
ping['192.168.192.28']={'Dlink_portail',0}
-- ----------------------------------------------------------------------------
local scriptName = 'ARPing'
local scriptVersion = '1.0'
return {
active = true,
logging = {
--level = domoticz.LOG_DEBUG, -- Uncomment to override the dzVents global logging setting
marker = scriptName..' '..scriptVersion
},
on = {
timer = {
'every '..tostring(fetchIntervalMins)..' minutes',
},
},
execute = function(domoticz, item)
local arp = {} -- Table pour les lignes du fichier
if (domoticz.utils.fileExists("/proc/net/arp"))then
local file = io.open("/proc/net/arp", "r") -- Ouvre le fichier en mode lecture
local ligne = {} -- Table pour les lignes du fichier
for line in file:lines() do -- Pour chaque lignes
table.insert(arp, line) -- On insère les lignes dans la table
end
i =0
for i,r in pairs(arp) do
switch = arp[i]:sub(1,arp[i]:find(" ")-1) --Extraction des IP de la table ARP
if(ping[switch]~=nil)then -- IP recherchée
if arp[i]:find("0x2")~=nil then --Flag 0x2 => IP connue sur le réseau, connectée
domoticz.log("arp success "..ping[switch][1], domoticz.LOG_DEBUG)
ping[switch][2]=1 -- flag pour mise à On
else
--Adresse IP connue mais déconnectée
domoticz.log("arp fail "..ping[switch][1], domoticz.LOG_DEBUG)
ping[switch][2]=2 -- Flag pour mise à Off
end
end
end
for ip, switch in pairs(ping) do
os.execute('ping -c10 -W1 '..ip..' &') -- lancement d'un ping sur les IP à tester pour forcer la MAJ ARP
if(switch[2]==1)then
domoticz.log(ip..' '..switch[1]..' On actuellement '..domoticz.devices(switch[1]).state, domoticz.LOG_DEBUG)
if (domoticz.devices(switch[1]).state=='Off')then
domoticz.devices(switch[1]).switchOn()
end
elseif(switch[2]==2)then
domoticz.log(ip..' '..switch[1]..' Off actuellement '..domoticz.devices(switch[1]).state, domoticz.LOG_DEBUG)
if (domoticz.devices(switch[1]).state=='On')then
domoticz.devices(switch[1]).switchOff()
end
else
--@IP non trouvée dans le fichier ARP
--On le ping à l'ancienne
domoticz.log("IP "..ip.." non trouvée dans ARP", domoticz.LOG_DEBUG)
if os.execute('ping -c1 -W1 '..ip) then
domoticz.log("Ping "..ip.." "..switch[1].." On actuellement "..domoticz.devices(switch[1]).state, domoticz.LOG_DEBUG)
if (domoticz.devices(switch[1]).state=='Off')then
domoticz.devices(switch[1]).switchOn()
end
else
domoticz.log("IP injoignable "..switch[1].." Off actuellement "..domoticz.devices(switch[1]).state, domoticz.LOG_DEBUG)
if (domoticz.devices(switch[1]).state=='On')then
domoticz.devices(switch[1]).switchOff()
end
end
end
end
else
domoticz.log('Erreur lecture fichier arp', domoticz.LOG_ERROR)
end
end
}
Merci pour ton aide
Dz version : 2024.7
Rpi 4 avec dongle téléinfo, GPIO pour le moment !
Rpi 4 avec dongle téléinfo, GPIO pour le moment !
Re: System Alive Checker (Ping) et TV sharp
Il n'y a pas de dépendance à installer, j'appelle directement le fichier qui stoke la table arp.
Il faut au moins la version 2.4 de DzVents qui intègre les "utils".
Tu peux éventuellement remplacer la ligne par
en attendant de faire la mise à jour.
Il faut au moins la version 2.4 de DzVents qui intègre les "utils".
Tu peux éventuellement remplacer la ligne par
Code : Tout sélectionner
if (true)then
Re: System Alive Checker (Ping) et TV sharp
ça marche impec, reste à voir quand un des périphérique sera OFF !
merci pour ta réponse
merci pour ta réponse
Dz version : 2024.7
Rpi 4 avec dongle téléinfo, GPIO pour le moment !
Rpi 4 avec dongle téléinfo, GPIO pour le moment !