Exemplo n.º 1
0
def onHeartbeat():
    global isConnected, nextConnect, oustandingPings, playerID
    if (isConnected == True):
        if (oustandingPings > 6):
            Domoticz.Disconnect()
            nextConnect = 0
        else:
            if (playerID == -1):
                Domoticz.Send(
                    '{"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1001}'
                )
            else:
                Domoticz.Send(
                    '{"jsonrpc":"2.0","method":"Player.GetProperties","id":1002,"params":{"playerid":'
                    + str(playerID) +
                    ',"properties":["live","percentage","speed"]}}')
            oustandingPings = oustandingPings + 1
    else:
        # if not connected try and reconnected every 3 heartbeats
        oustandingPings = 0
        nextConnect = nextConnect - 1
        if (nextConnect <= 0):
            nextConnect = 3
            Domoticz.Connect()
    return True
Exemplo n.º 2
0
def onHeartbeat():
    global isConnected, nextConnect, oustandingPings
    if (isConnected == True):
        if (oustandingPings > 5):
            Domoticz.Disconnect()
            nextConnect = 0
        else:
            Domoticz.Send('PW?\r')
            oustandingPings = oustandingPings + 1
    else:
        # if not connected try and reconnected every 3 heartbeats
        oustandingPings = 0
        nextConnect = nextConnect - 1
        if (nextConnect <= 0):
            nextConnect = 3
            Domoticz.Connect()
    return
Exemplo n.º 3
0
def onHeartbeat():
    global isConnected, nextConnect, oustandingPings, lastMessage, pollingDict
    if (isConnected == True):
        if (oustandingPings > 5):
            Domoticz.Disconnect()
            nextConnect = 0
        else:
            Domoticz.Send(pollingDict[lastMessage])
            Domoticz.Debug("onHeartbeat: lastMessage "+lastMessage+", Sending '"+pollingDict[lastMessage][0:2]+"'.")
            oustandingPings = oustandingPings + 1
    else:
        # if not connected try and reconnected every 3 heartbeats
        oustandingPings = 0
        nextConnect = nextConnect - 1
        if (nextConnect <= 0):
            nextConnect = 3
            Domoticz.Connect()
    return
Exemplo n.º 4
0
 def onHeartbeat(self):
     if (self.KodiConn.Connected() == True):
         if (self.oustandingPings > 6):
             Domoticz.Disconnect()
             self.nextConnect = 0
         else:
             if (self.playerID == -1):
                 self.KodiConn.Send('{"jsonrpc":"2.0","method":"Player.GetActivePlayers","id":1001}')
             else:
                 self.KodiConn.Send('{"jsonrpc":"2.0","method":"Player.GetProperties","id":1002,"params":{"playerid":' + str(self.playerID) + ',"properties":["live","percentage","speed"]}}')
             self.oustandingPings = self.oustandingPings + 1
     else:
         # if not connected try and reconnected every 3 heartbeats
         self.oustandingPings = 0
         self.nextConnect = self.nextConnect - 1
         if (self.nextConnect <= 0):
             self.nextConnect = 3
             Domoticz.Connect()
     return True
Exemplo n.º 5
0
 def onHeartbeat(self):
     if (self.isConnected == True):
         if (self.oustandingPings > 5):
             Domoticz.Disconnect()
             self.nextConnect = 0
         else:
             Domoticz.Send(self.pollingDict[self.lastMessage])
             Domoticz.Debug("onHeartbeat: self.lastMessage "+self.lastMessage+", Sending '"+self.pollingDict[self.lastMessage][0:2]+"'.")
             self.oustandingPings = self.oustandingPings + 1
     else:
         # if not connected try and reconnected every 3 heartbeats
         self.oustandingPings = 0
         self.nextConnect = self.nextConnect - 1
         if (self.nextConnect <= 0):
             self.nextConnect = 3
             Domoticz.Connect()
             
     self.lastHeartbeat = datetime.datetime.now()
     return