Aller au contenu

Arreter Ou Rebooter Votre Synology Avec La Hc2


fdp2

Messages recommandés

Bonjour, 

 

Depuis la mise à jour du NAS Synology DSM 7.0-41890    je n'arrive plus à éteindre le serveur via le HC2.   Un retour chez certain svp ? 

 

Merci

 

ps: voici ce que je constate sur le HC2 lorsque je fais  "déboguer"

 

[DEBUG] 14:55:44: Version API Synology OK
[DEBUG] 14:55:44: Chemin API Synology = entry.cgi
[ERROR] 14:55:44: line 76: attempt to concatenate field '?' (a nil value)
 

Lien vers le commentaire
Partager sur d’autres sites

Bonsoir,

 

Rechercher cette ligne :

payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=2&account="..login.."&passwd="..password.."&session=DSM&format=sid";

Et changez-la avec celle-ci:

payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=7&account="..login.."&passwd="..password.."&session=DSM&format=sid";

C'est en général un problème de version de l'API à utiliser pour se connecter.

Modifié par Kana-chan
Lien vers le commentaire
Partager sur d’autres sites

  • 5 semaines après...
Le 11/10/2021 à 00:11, Kana-chan a dit :

Bonsoir,

 

Rechercher cette ligne :


payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=2&account="..login.."&passwd="..password.."&session=DSM&format=sid";

Et changez-la avec celle-ci:


payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=7&account="..login.."&passwd="..password.."&session=DSM&format=sid";

C'est en général un problème de version de l'API à utiliser pour se connecter.

Bonsoir, 

Pardon, je n'avais pas vu que tu m'avais répondu... je vois seulement ta réponse. Merci pour le retour. 
De mon côté voici ce que j'ai payload = "/webapi/"..pathAuth.."?api=SYNO.API.Auth&method=Login&version=7&account="..login.."&passwd="..password.."&session=DSM&format=sid"

Il me semble que c'est déjà ce qui est en place de mon côté non ? 

En te remerciant, 

Lien vers le commentaire
Partager sur d’autres sites

Bonsoir,

 

Je suis passé sur une HC3.

Et je ne sais pas quel VD vous utilisez.

Pouvez-vous y mettre le code ici dans une balise code ?

Car sur ma HC3, le redémarrage et l'arrêt fonctionnent.

Merci.

 

 

Modifié par Kana-chan
Lien vers le commentaire
Partager sur d’autres sites

  • 8 mois après...
Le 11/11/2021 à 17:40, Kana-chan a dit :

Bonsoir,

 

Je suis passé sur une HC3.

Et je ne sais pas quel VD vous utilisez.

Pouvez-vous y mettre le code ici dans une balise code ?

Car sur ma HC3, le redémarrage et l'arrêt fonctionnent.

Merci.

 

 

Bonjour, 

 

Voici ce qui est dans la boucle principale du VD

 

---------------------------------------------------------------------------------------------
-- OBJECTIF
-- Ce VD permet le monitoring de votre Synology
--    - ping toutes les 10sec
--    - reboot (protégé par double click)
--    - shutdow (protégé par double click)
--    - Wake On Lan
-- La variable globale "Syno_Status" (créée automatiquement)
--    contient le status actuel du Syno pour utilisation dans GEA ou ailleurs
-- Un message push est envoyé aux Portables listés dans la table "pushID"
--
-- FIRMWARE
-- v4.x
-- url : http://www.domotique-fibaro.fr/index.php/topic/5682-synology-monitoring/?p=85693
--
-- HISTORIQUE
-- v2.41(02/09/2015 - jojo) : slider pour double click
-- v2.4 (29/08/2015 - jojo) : première version
--                            merci à Krikroff, Lazer, Steven, mprinfo, FDP2
----------------------------------------------------------------------------------------------

----------------------------------
-- User Settings
----------------------------------
local pushID = {2} -- 0 = no push; sinon entrer les ID séparés par une ,
local refresh = 10 -- seconds
local okIcon = 1094
local nokIcon = 1095

----------------------------------
-- DO not change bellow this line
----------------------------------
-- System variables
local selfID = fibaro:getSelfId()
local _deviceIp = fibaro:get(selfID, 'IPAddress')
local _devicePort = fibaro:get(selfID, 'TCPPort')
local _maxRetryProcess = 2

-- Main object
if (CheckRecording == nil) then
	CheckRecording = {
		-- System variables
		selfID = fibaro:getSelfId(),
		
		-- fonction push notification
		_push = function(self)
			msg = "Serveur " ..status.. " - IP = " .._deviceIp.. ":" .._devicePort
			if pushID[1] ~= 0 then
				for i = 1, #pushID do
					fibaro:debug("pushID = " ..pushID[i])
					fibaro:call(pushID[i], "sendPush", msg.." ("..os.date("%d/%m à %H:%M")..")")
				end
			else
				fibaro:debug("No push")
			end
		end,
		
		-- recursive function to ping device
		_ping = function(self)
			retry = 0
			pingOK = false
			while (pingOK == false and retry < _maxRetryProcess) do
				--open the socket
				local tcpSocket = Net.FTcpSocket(_deviceIp, _devicePort)
				--set the read timeout
				tcpSocket:setReadTimeout(250)
				--notify user
				fibaro:log("Search on the local network, try #" .. retry .. " please wait...")
				fibaro:sleep(250)
				--send packet
				local bytes, errorCode = tcpSocket:write("test")
				--check for error  	
				if errorCode == 0 then
					pingOK = true
				else
					retry = retry + 1
					fibaro:log("Retry process, please wait...")
					fibaro:sleep(1000)
				end
			end
		end,

		-- Main code
		main = function(self)
			-- fibaro:setGlobal('Syno_Status', "test")
			status = fibaro:getGlobal("Syno_Status")
			if (status ~= "Allumé" and status ~= "Eteint") then
				fibaro:debug ("Pause 2 min")
				fibaro:sleep (2*60*1000) -- pause 2 min
			end
			heure = os.date("%H:%M:%S")
			date = os.date("%d/%m")
			dateheure = string.format("le %s à %s", date, heure)
			
			--ping device
			CheckRecording:_ping()
			if pingOK == true then
				fibaro:call(self.selfID, "setProperty", "currentIcon", okIcon)
				if status ~= "Allumé" then
					status = "Allumé"
					fibaro:setGlobal('Syno_Status', "Allumé")
					CheckRecording:_push()
				end
			else
				fibaro:call(self.selfID, "setProperty", "currentIcon", nokIcon)
				if status ~= "Eteint" then
					status = "Eteint"
					fibaro:setGlobal('Syno_Status', "Eteint")
					CheckRecording:_push()
				end
			end
			fibaro:call(self.selfID, "setProperty", "ui.LabStatus.value", status)
			fibaro:log("Serveur " ..status.. " - IP = " .._deviceIp..":".._devicePort)
			fibaro:debug("Status = " ..status)
			fibaro:call(self.selfID, "setProperty", "ui.LabLastCheck.value", dateheure)
			fibaro:call(self.selfID, "setProperty", "ui.LabServeur.value", _deviceIp..":".._devicePort)
		
			-- Wait
			fibaro:sleep((refresh-3)*1000)
		end
	}
	
	-- Syno_Status variable check & creation if needed
	local HC2 = Net.FHttp("127.0.0.1",11111)
	local response, status, error = HC2:GET("/api/globalVariables/")
	Variables = json.decode(response)
	local Exist = false
	for  _, v in pairs(Variables) do
		if v.name == "Syno_Status" then 
			fibaro:debug('La variable "Syno_Status" existe.')
			Exist = true
		end
	end
	-- création de la variable "Syno_Status" si elle n'existe pas
	if Exist == false then
		temp = '{"name":"Syno_Status", "isEnum":0, "value":""}'
		HC2:POST("/api/globalVariables", temp)
		fibaro:debug('La variable "Syno_Status" a été créée.')
	end
	
	fibaro:debug("Function successfully loaded in memory")
end

-- Start
CheckRecording:main()

 

Lien vers le commentaire
Partager sur d’autres sites

Bonsoir,

 

Là comme cela, je ne vois pas.

Essayer avec le VD que je mets en PJ en remplaçant les "fibaro:getGlobal()" dans login et password par vos login et password de votre NAS Synology.

Si cela ne fonctionne pas, jouer avec la version des API pour la connexion de type Login.

 

Synology_DSM7.vfib

Modifié par Kana-chan
Lien vers le commentaire
Partager sur d’autres sites

  • 8 mois après...
  • 9 mois après...
×
×
  • Créer...