Beispiel #1
0
 private function CheckParents()
 {
     $result = $this->HasActiveParent();
     if ($result) {
         $instance = IPS_GetInstance($this->InstanceID);
         $parentGUID = IPS_GetInstance($instance['ConnectionID'])['ModuleInfo']['ModuleID'];
         if ($parentGUID == '{61051B08-5B92-472B-AFB2-6D971D9B99EE}') {
             IPS_DisconnectInstance($this->InstanceID);
             IPS_LogMessage('XBee-ZigBee Gateway', 'XB-ZB Gateway has invalid Parent.');
             $result = false;
         }
     }
     return $result;
 }
 private function CheckParents()
 {
     $result = $this->HasActiveParent();
     if ($result) {
         $instance = IPS_GetInstance($this->InstanceID);
         $parentGUID = IPS_GetInstance($instance['ConnectionID'])['ModuleInfo']['ModuleID'];
         if ($parentGUID == '{79827379-F36E-4ADA-8A95-5F8D1DC92FA9}') {
             IPS_DisconnectInstance($this->InstanceID);
             //IPS_LogMessage('Logamatic Gateway', 'Logamatic Gateway has invalid Parent.');
             $result = false;
         }
     }
     return $result;
 }
Beispiel #3
0
 private function CheckParents()
 {
     $result = $this->HasActiveParent();
     if ($result) {
         $instance = IPS_GetInstance($this->InstanceID);
         $parentGUID = IPS_GetInstance($instance['ConnectionID'])['ModuleInfo']['ModuleID'];
         if ($parentGUID == '{3CFF0FD9-E306-41DB-9B5A-9D06D38576C3}') {
             IPS_DisconnectInstance($this->InstanceID);
             IPS_LogMessage('EHz', 'EHz has invalid Parent.');
             $result = false;
         }
     }
     return $result;
 }
function GetOrCreateHMDevice($Parent, $Name, $Address, $Protocol, $HMParent)
{
    $ObjID = IPS_CreateInstance("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
    if (IPS_GetInstance($ObjID)['ConnectionID'] != $HMParent) {
        IPS_DisconnectInstance($ObjID);
        IPS_ConnectInstance($ObjID, $HMParent);
    }
    IPS_SetParent($ObjID, $Parent);
    IPS_SetName($ObjID, $Name);
    IPS_SetProperty($ObjID, 'Address', $Address);
    IPS_SetProperty($ObjID, 'Protocol', $Protocol);
    IPS_SetProperty($ObjID, 'EmulateStatus', false);
    usleep(50000);
    @IPS_ApplyChanges($ObjID);
    /* 	 {
         echo "Error beim Erzeugen von Gerät ".$Address.PHP_EOL;
         //	 echo "  Gerät mit Namen ".$Name." wird wieder gelöscht.".PHP_EOL;
         //	 IPS_DeleteInstance($ObjID);
         //	 return false;
         } */
    return $ObjID;
}
Beispiel #5
0
 public function CreateAllPlayer()
 {
     $players = $this->GetNumberOfPlayers();
     if ($players === false) {
         return false;
     }
     $DevicesIDs = IPS_GetInstanceListByModuleID("{118189F9-DC7E-4DF4-80E1-9A4DF0882DD7}");
     $CreatedPlayers = array();
     foreach ($DevicesIDs as $Device) {
         $KnownDevices[] = IPS_GetProperty($Device, 'Address');
     }
     for ($i = 0; $i < $players; $i++) {
         $player = $this->SendLMSData(new LMSData(array('player', 'id', $i), '?'));
         if ($player === false) {
             continue;
         }
         $playermac = rawurldecode($player);
         if (in_array($playermac, $KnownDevices)) {
             continue;
         }
         $NewDevice = IPS_CreateInstance("{118189F9-DC7E-4DF4-80E1-9A4DF0882DD7}");
         $playerName = $this->SendLMSData(new LMSData(array('player', 'name', $i), '?'));
         IPS_SetName($NewDevice, $playerName);
         if (IPS_GetInstance($NewDevice)['ConnectionID'] != $this->InstanceID) {
             @IPS_DisconnectInstance($NewDevice);
             IPS_ConnectInstance($NewDevice, $this->InstanceID);
         }
         IPS_SetProperty($NewDevice, 'Address', $playermac);
         IPS_ApplyChanges($NewDevice);
         $CreatedPlayers[] = $NewDevice;
     }
     return $CreatedPlayers;
 }
Beispiel #6
0
  public function SyncDevices() {
    $lightsCategoryId = $this->GetLightsCategory();

    $lights = $this->Request('/lights');
    foreach ($lights as $lightId => $light) {
      $name = utf8_decode((string)$light->name);
      $uniqueId = (string)$light->uniqueid;
      echo "$lightId. $name ($uniqueId)\n";

      $deviceId = $this->GetDeviceByUniqueId($uniqueId);

      if ($deviceId == 0) {
        $deviceId = IPS_CreateInstance($this->DeviceGuid());
        IPS_SetProperty($deviceId, 'UniqueId', $uniqueId);
      }

      IPS_SetParent($deviceId, $lightsCategoryId);
      IPS_SetProperty($deviceId, 'LightId', (integer)$lightId);
      IPS_SetName($deviceId, $name);

      // Verbinde Light mit Bridge
      if (IPS_GetInstance($deviceId)['ConnectionID'] <> $this->InstanceID) {
        @IPS_DisconnectInstance($deviceId);
        IPS_ConnectInstance($deviceId, $this->InstanceID);
      }

      IPS_ApplyChanges($deviceId);
      HUE_RequestData($deviceId);
    }
  }