diff --git a/IPSViewConnect/module.php b/IPSViewConnect/module.php index 6959958..6772efc 100644 --- a/IPSViewConnect/module.php +++ b/IPSViewConnect/module.php @@ -182,7 +182,10 @@ protected function GetViewIDByName($viewName) { } } if ($viewID === false) { - $snapshot = json_decode(IPS_GetSnapshot(), true); + $snapshot = IPS_GetSnapshot(); + if (!is_array($snapshot)) { + $snapshot = json_decode($snapshot, true); + } if ($snapshot == null) { throw new Exception('Error during json_decode of Snapshot in GetViewIDByName!'); } @@ -242,7 +245,10 @@ protected function GetInstanceIDUserViews() { // ------------------------------------------------------------------------- protected function API_GetSnapshot($params) { - $snapshot = json_decode(IPS_GetSnapshot(), true); + $snapshot = IPS_GetSnapshot(); + if (!is_array($snapshot)) { + $snapshot = json_decode($snapshot, true); + } if ($snapshot == null) { throw new Exception('Error during json_decode of Snapshot!'); } @@ -332,7 +338,9 @@ protected function API_GetSnapshotChanges($params) { if ($changes === false) { throw new Exception('Error receiving SnapshotChanges: '.print_r(error_get_last(), true)); } - $changes = json_decode($changes, true); + if (!is_array($changes)) { + $changes = json_decode($changes, true); + } $result = Array(); foreach ($changes as $change) { @@ -422,7 +430,10 @@ protected function API_AssignViewData($method, $params) { $view=null; // Add special IP-Symcon Instance IDs - $snapshot = json_decode(IPS_GetSnapshot(), true); + $snapshot = IPS_GetSnapshot(); + if (!is_array($snapshot)) { + $snapshot = json_decode($snapshot, true); + } if ($snapshot == null) { throw new Exception('Error during json_decode of Snapshot in AssignViewData!'); } @@ -627,7 +638,11 @@ protected function ProcessHookAPIMethod($method, $params) { } else if ($method == 'IPS_GetSnapshotChanges') { return $this->API_GetSnapshotChanges($params); } else if ($method == 'IPS_GetPresentations') { - return IPS_GetPresentations(); + $presentations = IPS_GetPresentations(); + if (is_array($presentations)) { + $presentations = json_encode($presentations); + } + return $presentations; } else if ($method == 'IPS_GetLicensee') { return IPS_GetLicensee();