Re: [DzVents] LiveBox 4
Publié : 24 oct. 2018, 21:03
Ce qui me surprend le plus, c'est qu'une des requêtes fonctionne...
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Bonjour NeutrinoNeutrino a écrit : 24 oct. 2018, 21:03C'est quoi ta version de firmware ?
Ce qui me surprend le plus, c'est qu'une des requêtes fonctionne...
Oui j'ai redémarré la box, mais pas de changement.
Code : Tout sélectionner
[
{
"Name": "papoo",
"Phone": "0607080910"
},
{
"Name": "lambda",
"Phone": "0605040302"
}
]
Code : Tout sélectionner
local fichier_contacts = "/home/pi/domoticz/scripts/contacts.json"Code : Tout sélectionner
json = assert(loadfile('/home/pi/domoticz/scripts/lua/JSON.lua'))()Code : Tout sélectionner
function json2table(file)
local f = io.open(file, "rb")
if(f == nil) then
return ""
else
local content = f:read("*all")
f:close()
jsonValeur = json:decode(content)
return jsonValeur
end
endCode : Tout sélectionner
contacts = {}Code : Tout sélectionner
contacts = json2table(fichier_contacts)Code : Tout sélectionner
function searchName(contacts, phoneNumber)
for index, variable in pairs(contacts) do
if variable.Phone == phoneNumber then
name = variable.Name
end
end
if name == nil then
name = phoneNumber
end
return name
endCode : Tout sélectionner
call.remoteNumberCode : Tout sélectionner
searchName(contacts, call.remoteNumber)Code : Tout sélectionner
2018-11-25 15:47:00.361 Status: dzVents: Info: Livebox 1.7: ------ Start external script: livebox.lua:, trigger: every 1 minutes
2018-11-25 15:47:03.685 Status: dzVents: Error (2.4.8): Livebox 1.7: An error occured when calling event handler livebox
2018-11-25 15:47:03.685 Status: dzVents: Error (2.4.8): Livebox 1.7: /home/pat/domoticz/scripts/dzVents/scripts/livebox.lua:219: attempt to index field 'dhcp_data' (a nil value)
2018-11-25 15:47:03.685 Status: dzVents: Info: Livebox 1.7: ------ Finished livebox.luaCode : Tout sélectionner
#!/bin/bash
###########################################
# Firmware Livebox 4 = 3.4.10 g0-f-sip-fr #
# Script mis a jour le 06/04/2018 #
###########################################
#Source : https://www.alex-braga.fr/ressources_externe/xdslbox_3.4.10.sh
# https://github.com/rene-d/sysbus
#############################
# Declaration des variables #
#############################
myLivebox="192.168.1.1"
myPassword="motdepasse"
myBashDir=/var/tmp
myOutput=$myBashDir/myOutput.txt
myCookies=$myBashDir/myCookies.txt
########################################
# Connexion et recuperation du cookies #
########################################
curl -s -o "$myOutput" -X POST -c "$myCookies" -H 'Content-Type: application/x-sah-ws-4-call+json' -H 'Authorization: X-Sah-Login' -d "{\"service\":\"sah.Device.Information\",\"method\":\"createContext\",\"parameters\":{\"applicationName\":\"so_sdkut\",\"username\":\"admin\",\"password\":\"$myPassword\"}}" http://$myLivebox/ws > /dev/null
##################################################
# Lecture du cookies pour utilisation ulterieure #
##################################################
myContextID=$(tail -n1 "$myOutput" | sed 's/{"status":0,"data":{"contextID":"//1'| sed 's/",//1' | sed 's/"groups":"http,admin//1' | sed 's/"}}//1')
###############################################################################################
# Envoi des commandes pour recuperer les informtations et ecriture dans un fichier TXT separe #
###############################################################################################
getMIBs=`curl -s -b "$myCookies" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H "X-Context: $myContextID" -d "{\"service\":\"NeMo.Intf.data\",\"method\":\"getMIBs\",\"parameters\":{}}" http://$myLivebox/ws`
echo $getMIBs > $myBashDir/MIBs.txt
getDSLStats=`curl -s -i -b "$myCookies" -X POST -H 'Content-Type: application/json' -H 'X-Context: '$cookiesContextID'' -d '{"parameters":{}}' http://$myLivebox/sysbus/NeMo/Intf/dsl0:getDSLStats | tail -n1`
echo $getDSLStats > $myBashDir/DSLStats.txt
getWANStatus=`curl -s -i -b "$myCookies" -X POST -H 'Content-Type: application/json' -H 'X-Context: '$cookiesContextID'' -d '{"parameters":{}}' http://$myLivebox/sysbus/NMC:getWANStatus | tail -n1`
echo $getWANStatus > $myBashDir/WANStatus.txt
#######################################################
# Deconnexion et suppression des fichiers temporaires #
#######################################################
curl -s -b "$myCookies" -X POST http://$myLivebox/logout
rm "$myCookies" "$myOutput"