I'm trying to develop a plugin. I'm not a developer, it's more learning on the job
If I do it from the commandline it's working perfect:
Code: Select all
curl --silent --cookie /tmp/json_c-H "Content-Type: application/json" -X POST -d "{\"username\":\"USERNAME\",\"password\":\"Welcome123\"}" https://IPAddress:8443/api/login
Code: Select all
def onStart(self):
Domoticz.Log("Calling onStart")
self.httpConn = Domoticz.Connection(Name="Test", Transport="TCP/IP", Protocol="HTTPS", Address="172.0.0.1", Port="8443")
self.httpConn.Connect()
Domoticz.Log("Ending onStart")
def onStop(self):
Domoticz.Log("Plugin is stopping.")
Domoticz.Debugging(0)
def onConnect(self, Connection, Status, Description):
Domoticz.Log("Calling onConnect")
Domoticz.Log("Status = "+str(Status))
if (Status == 0):
Domoticz.Debug("Trying to login to the api.")
sendData = { 'Verb' : 'POST',
'URL' : '/api/login',
'Headers' : { 'Content-Type': 'application/json; charset=utf-8', \
'Connection': 'keep-alive', \
'Accept': 'Content-Type: application/json; charset=UTF-8', \
'User-Agent':'Domoticz/1.0' },
'Data' : { 'username':'USERNAME','password':'Welcome123' }
}
Connection.Send(sendData)
DumpHTTPResponseToLog(sendData)
Domoticz.Log("Successfully logged in.")
Can someone help me?