本文整理汇总了PHP中IPS_GetProperty函数的典型用法代码示例。如果您正苦于以下问题:PHP IPS_GetProperty函数的具体用法?PHP IPS_GetProperty怎么用?PHP IPS_GetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IPS_GetProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ApplyChanges
public function ApplyChanges()
{
//Never delete this line!
parent::ApplyChanges();
$change = false;
// Zwangskonfiguration des ClientSocket
$ParentID = $this->GetParent();
if (!($ParentID === false)) {
if (IPS_GetProperty($ParentID, 'Host') != $this->ReadPropertyString('Host')) {
IPS_SetProperty($ParentID, 'Host', $this->ReadPropertyString('Host'));
$change = true;
}
if (IPS_GetProperty($ParentID, 'Port') != $this->ReadPropertyInteger('Port')) {
IPS_SetProperty($ParentID, 'Port', $this->ReadPropertyInteger('Port'));
$change = true;
}
$ParentOpen = $this->ReadPropertyBoolean('Open');
// Keine Verbindung erzwingen wenn Host leer ist, sonst folgt später Exception.
if (IPS_GetProperty($ParentID, 'Open') != $ParentOpen) {
IPS_SetProperty($ParentID, 'Open', $ParentOpen);
$change = true;
}
if ($change) {
@IPS_ApplyChanges($ParentID);
}
}
/* Eigene Profile
*/
//Workaround für persistente Daten der Instanz
// Wenn wir verbunden sind, am Gateway mit listen anmelden für Events
if ($this->ReadPropertyBoolean('Open') and $this->HasActiveParent($ParentID)) {
$this->SetStatus(102);
}
}
示例2: ProcessHookData
/**
* This function will be available automatically after the module is imported with the module control.
* Using the custom prefix this function will be callable from PHP and JSON-RPC through:
*
* LOCATIVE_ProcessHookData($id);
*
*/
public function ProcessHookData()
{
if ($_IPS['SENDER'] == "Execute") {
echo "This script cannot be used this way.";
return;
}
if (IPS_GetProperty($this->InstanceID, "Username") != "" || IPS_GetProperty($this->InstanceID, "Password") != "") {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
$_SERVER['PHP_AUTH_USER'] = "";
}
if (!isset($_SERVER['PHP_AUTH_PW'])) {
$_SERVER['PHP_AUTH_PW'] = "";
}
if ($_SERVER['PHP_AUTH_USER'] != IPS_GetProperty($this->InstanceID, "Username") || $_SERVER['PHP_AUTH_PW'] != IPS_GetProperty($this->InstanceID, "Password")) {
header('WWW-Authenticate: Basic Realm="Locative WebHook"');
header('HTTP/1.0 401 Unauthorized');
echo "Authorization required";
return;
}
}
/**
The following $_POST data are slightly different from Geofency
**/
if (!isset($_POST['device']) || !isset($_POST['id']) || !isset($_POST['trigger'])) {
IPS_LogMessage("Locative", "Malformed data: " . print_r($_POST, true));
return;
}
$trigger = strtolower(isset($_POST["trigger"]) ? $_POST["trigger"] : "");
$name = htmlentities(utf8_decode(isset($_REQUEST["name"]) ? $_REQUEST["name"] : "Home"));
IPS_LogMessage("IPSLocative", print_r($_REQUEST, true));
$deviceID = $this->CreateInstanceByIdent($this->InstanceID, $this->ReduceGUIDToIdent($_POST['device']), "Device");
SetValue($this->CreateVariableByIdent($deviceID, "Latitude", "Latitude", 2), floatval($_POST['latitude']));
SetValue($this->CreateVariableByIdent($deviceID, "Longitude", "Longitude", 2), floatval($_POST['longitude']));
SetValue($this->CreateVariableByIdent($deviceID, "Time", "Time", 1, "~UnixTimestamp"), $_POST['timestamp']);
SetValue($this->CreateVariableByIdent($deviceID, "LastTrigger", "LastTrigger", 3), $trigger);
$varID = $this->CreateVariableByIdent($deviceID, $name, $name, 0, "~Presence");
switch ($trigger) {
case "enter":
SetValue($varID, 1);
echo "Welcome!";
break;
case "exit":
SetValue($varID, 0);
echo "Bye!";
break;
case "test":
$status = isset($_GET["status"]) ? $_GET["status"] == "1" : false;
echo "Test for {$name} received. Status {$status}";
SetValue($varID, $status);
break;
}
}
示例3: RegisterHook
private function RegisterHook($Hook, $TargetID)
{
$ids = IPS_GetInstanceListByModuleID("{015A6EB8-D6E5-4B93-B496-0D3F77AE9FE1}");
if (sizeof($ids) > 0) {
$hooks = json_decode(IPS_GetProperty($ids[0], "Hooks"), true);
$found = false;
foreach ($hooks as $index => $hook) {
if ($hook['Hook'] == "/hook/ips4WinDeviceReg") {
if ($hook['TargetID'] == $TargetID) {
return;
}
$hooks[$index]['TargetID'] = $TargetID;
$found = true;
}
}
if (!$found) {
$hooks[] = array("Hook" => "/hook/ips4WinDeviceReg", "TargetID" => $TargetID);
}
IPS_SetProperty($ids[0], "Hooks", json_encode($hooks));
IPS_ApplyChanges($ids[0]);
}
}
示例4: RequestRead
public function RequestRead()
{
$Address = 0x0 + ($this->ReadPropertyInteger("Phase") - 1) * 2;
$Volt = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => "")));
if ($Volt === false) {
return;
}
$Volt = unpack("n*", substr($Volt, 2));
$Address = 0xc + ($this->ReadPropertyInteger("Phase") - 1) * 2;
$Ampere = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => "")));
if ($Ampere === false) {
return;
}
$Ampere = unpack("n*", substr($Ampere, 2));
$Address = 0x12 + ($this->ReadPropertyInteger("Phase") - 1) * 2;
$Watt = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => "")));
if ($Watt === false) {
return;
}
$Watt = unpack("n*", substr($Watt, 2));
$Address = 0x46 + ($this->ReadPropertyInteger("Phase") - 1) * 2;
$KWh = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => "")));
if ($KWh === false) {
return;
}
$KWh = unpack("n*", substr($KWh, 2));
if (IPS_GetProperty(IPS_GetInstance($this->InstanceID)['ConnectionID'], "SwapWords")) {
SetValue($this->GetIDForIdent("Volt"), ($Volt[1] + ($Volt[2] << 16)) / 10);
SetValue($this->GetIDForIdent("Ampere"), ($Ampere[1] + ($Ampere[2] << 16)) / 1000);
SetValue($this->GetIDForIdent("Watt"), ($Watt[1] + ($Watt[2] << 16)) / 10);
SetValue($this->GetIDForIdent("kWh"), ($KWh[1] + ($KWh[2] << 16)) / 10);
} else {
SetValue($this->GetIDForIdent("Volt"), ($Volt[2] + ($Volt[1] << 16)) / 10);
SetValue($this->GetIDForIdent("Ampere"), ($Ampere[2] + ($Ampere[1] << 16)) / 1000);
SetValue($this->GetIDForIdent("Watt"), ($Watt[2] + ($Watt[1] << 16)) / 10);
SetValue($this->GetIDForIdent("kWh"), ($KWh[2] + ($KWh[1] << 16)) / 10);
}
}
示例5: SendSwitchData
/**
* Forward Switch data to SwitchDev instances
* Create one if needed
* @param array $data
*/
private function SendSwitchData($data)
{
//parsing was OK, start distributing
$this->debug(__FUNCTION__, 'Prepare');
$class = __CLASS__ . "-SW";
$Device = $data['DeviceID'];
$typ = $data['Typ'];
$found = false;
$instID = 0;
$caps = "Switch;Dimmer;Timer;FS20;TimerActionCode";
$instances = IPS_GetInstanceListByModuleID($this->module_interfaces['SwitchDev']);
foreach ($instances as $instID) {
$I = IPS_GetInstance($instID);
$iid = (string) IPS_GetProperty($instID, 'DeviceID');
$ityp = (string) IPS_GetProperty($instID, 'Typ');
$iclass = (string) IPS_GetProperty($instID, 'Class');
$this->debug(__FUNCTION__, "Check my Device '{$Device}'' with Instance {$instID}({$iid})");
if ($I['ConnectionID'] == $this->InstanceID) {
//my child
if ($iid == $Device && $iclass == $class && $ityp == $typ) {
$this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
$found = true;
break;
}
//if destdevice
}
//if
}
//for
if (!$found) {
//no free instance available, have to create a new one
if ($this->ReadPropertyBoolean('AutoCreate') == true) {
//new instance needed
$this->debug(__FUNCTION__, 'CREATE NEW Device');
$instID = $this->CreateSwitchDevice($data, $caps);
$found = true;
} else {
$this->debug(__FUNCTION__, 'Creating FS20 Device ID ' . $Device . ' disabled by Property AutoCreate');
IPS_LogMessage($class, 'Creating FS20 Device ID ' . $Device . ' disabled by Property AutoCreate');
}
//if autocreate
}
//if found
if ($found && $instID > 0) {
//send record to children
$json = json_encode(array("DataID" => $this->module_interfaces['SWD-RX'], "DeviceID" => $data['DeviceID'], "Typ" => $data['Typ'], "Class" => $class, "SWData" => $data));
$this->debug(__FUNCTION__, $json);
@$this->SendDataToChildren($json);
$datum = date('Y-m-d H:i:s', time());
$vid = @$this->GetIDForIdent('LastUpdate');
if ($vid) {
SetValueString($vid, $datum);
}
}
//found
}
示例6: isDebug
/**
* check if debug is enabled
* @return bool
*/
protected function isDebug()
{
$debug = @IPS_GetProperty($this->InstanceID, 'Debug');
return $debug === true;
}
示例7: SetSpdifInput
public function SetSpdifInput($input_instance)
{
$ip = $this->ReadPropertyString("IPAddress");
$timeout = $this->ReadPropertyString("TimeOut");
if ($timeout && Sys_Ping($ip, $timeout) != true) {
throw new Exception("Sonos Box " . $ip . " is not available");
}
if (@GetValue($this->GetIDForIdent("MemberOfGroup"))) {
$this->SetGroup(0);
}
include_once __DIR__ . "/sonosAccess.php";
$sonos = new SonosAccess($ip);
$sonos->SetAVTransportURI("x-sonos-htastream:" . IPS_GetProperty($input_instance, "RINCON") . ":spdif");
$sonos->Play();
}
示例8: GetIPGateway
protected function GetIPGateway()
{
$ParentID = $this->GetParent();
$IPGateway = IPS_GetProperty($ParentID, 'Host');
return $IPGateway;
}
示例9: die
if ($parent === false) {
die("Manuelle Angabe der ID für Gewerke nicht vorhanden!");
}
}
if ($ScriptCat == 0) {
$ScriptCat = GetOrCreateCategoryByName(0, "Aktions-Scripte");
} else {
$parent = @IPS_GetObject($ScriptCat);
if ($parent === false) {
die("Manuelle Angabe der ID für Scripte nicht vorhanden!");
}
}
$HMDevices = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
$HMAdresses = array();
foreach ($HMDevices as $HMDevice) {
$HMAdresses[] = IPS_GetProperty($HMDevice, "Address");
}
foreach ($HMCcuAddress as $Key) {
$HMParent = $HMSockets[$Key];
if (IPS_GetInstance($HMParent)['InstanceStatus'] != 102) {
if (IPS_GetInstance($HMParent)['InstanceStatus'] >= 200) {
if (@IPS_ApplyChanges($HMSocket) === false) {
echo "Homematic-Socket (" . IPS_GetName($HMParent) . ") mit der InstanzID " . $HMParent . " konnte nicht reaktiviert werden." . PHP_EOL;
}
}
if (IPS_GetInstance($HMParent)['InstanceStatus'] != 102) {
echo "Homematic-Socket (" . IPS_GetName($HMParent) . ") mit der InstanzID " . $HMParent . " ist nicht aktiv." . PHP_EOL;
echo " Überspinge alle Geräte dieser CCU" . PHP_EOL;
echo "--------------------------------------------------------------------" . PHP_EOL;
continue;
}
示例10: SendENData
/**
* Forward Energy data to EnergyDev instances
* Create one if needed
* @param $caps string
* @param $data array
*/
private function SendENData($caps, $data)
{
$this->debug(__FUNCTION__, 'Prepare');
$datum = date('Y-m-d H:i:s', time());
$data['Date'] = $datum;
$Device = $data['Id'];
$typ = $data['Typ'];
$branch = $data['Branch'];
$found = false;
$instID = 0;
$class = __CLASS__ . "-EN";
$instances = IPS_GetInstanceListByModuleID($this->module_interfaces['EnergyDev']);
foreach ($instances as $instID) {
$I = IPS_GetInstance($instID);
$iid = (string) IPS_GetProperty($instID, 'DeviceID');
$ityp = (string) IPS_GetProperty($instID, 'Typ');
$iclass = (string) IPS_GetProperty($instID, 'Class');
//$this->debug(__FUNCTION__, "Check my Device '$Device'' with Instance $instID($iid)");
if ($I['ConnectionID'] == $this->InstanceID) {
//my child
if ($iid == $Device && $iclass == $class && $ityp == $typ) {
$this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
$found = true;
break;
}
//if destdevice
}
//if
}
//for
if (!$found) {
//no free instance available, have to create a new one
if ($this->ReadPropertyBoolean('AutoCreate') == true) {
//new instance needed
$this->debug(__FUNCTION__, 'CREATE NEW Energy Device ' . $Device);
$instID = $this->CreateEnergyDevice($data, $caps);
$found = true;
} else {
$this->debug(__FUNCTION__, "Creating XS1 {$branch} Energy Device " . $Device . ' disabled by Property AutoCreate');
IPS_LogMessage(__CLASS__, "Creating XS1 {$branch} Energy Device " . $Device . ' disabled by Property AutoCreate');
}
//if autocreate
}
//if found
if ($found && $instID > 0) {
//send record to children
$json = json_encode(array("DataID" => $this->module_interfaces['EN-RX'], "DeviceID" => $Device, "Typ" => $typ, "Class" => $class, "ENData" => $data));
$this->debug(__FUNCTION__, "Json:" . $json);
@$this->SendDataToChildren($json);
}
//found
}
示例11: ReadBatteryStates
private function ReadBatteryStates()
{
$InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{A89F8DFA-A439-4BF1-B7CB-43D047208DDD}");
// FHT
$InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{2FD7576A-D2AD-47EE-9779-A502F23CABB3}");
// FS20 HMS
$InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{EE4A81C6-5C90-4DB7-AD2F-F6BBD521412E}");
// HomeMatic
$InstanzIDsListAll[] = IPS_GetInstanceListByModuleID("{101352E1-88C7-4F16-998B-E20D50779AF6}");
// Z-Wave
$a = 0;
$l = 0;
foreach ($InstanzIDsListAll as $InstanzIDsList) {
foreach ($InstanzIDsList as $InstanzID) {
$InstanzHersteller = IPS_GetInstance($InstanzID);
$InstanzHersteller = $InstanzHersteller["ModuleInfo"]["ModuleName"];
switch ($InstanzHersteller) {
case "FHT":
$InstanzHersteller = "FHT";
break;
case "HMS":
$InstanzHersteller = "HMS";
break;
case "HomeMatic Device":
$InstanzHersteller = "HomeMatic";
break;
case "Z-Wave Module":
$InstanzHersteller = "Z-Wave";
break;
}
//FHT
$VarID = @IPS_GetObjectIDByIdent('LowBatteryVar', $InstanzID);
if ($VarID !== false and $InstanzHersteller == "FHT") {
$Var = IPS_GetVariable($VarID);
$VarLastUpdated = $Var["VariableUpdated"];
$VarLastUpdatedDiffSek = time() - $VarLastUpdated;
$DeviceID = IPS_GetProperty($InstanzID, "Address");
$LowBat = GetValueBoolean($VarID);
if ($LowBat === true) {
$Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
$Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
$Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
$Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
$Batterien_AR["Alle"][$a]["Batterie"] = "LEER";
$Batterien_AR["Alle"][$a]["Hersteller"] = $InstanzHersteller;
$Batterien_AR["Alle"][$a]["ID"] = $DeviceID;
$Batterien_AR["Alle"][$a]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
$Batterien_AR["Alle"][$a]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
$Batterien_AR["Alle"][$a]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
$Batterien_AR["Leer"][$l]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
$Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
$Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
$Batterien_AR["Leer"][$l][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
$Batterien_AR["Leer"][$l]["Batterie"] = "LEER";
$Batterien_AR["Leer"][$l]["Hersteller"] = $InstanzHersteller;
$Batterien_AR["Leer"][$l]["ID"] = $DeviceID;
$Batterien_AR["Leer"][$l]["Hersteller_ID"] = $InstanzHersteller . " - " . $DeviceID;
$Batterien_AR["Leer"][$l]["LetztesVarUpdateTimestamp"] = $VarLastUpdated;
$Batterien_AR["Leer"][$l]["LetztesVarUpdateVorSek"] = $VarLastUpdatedDiffSek;
$a++;
$l++;
} else {
$Batterien_AR["Alle"][$a]["Name"] = $this->Umlaute_Ersetzen(IPS_GetName($InstanzID));
if ($this->ReadPropertyBoolean("NamenParentObjekt1CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr1NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle1TB"));
$Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt2CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr2NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle2TB"));
$Batterien_AR["Alle"][$a][$ParentNameTabelle] = $this->Umlaute_Ersetzen(IPS_GetName($ParentID));
}
if ($this->ReadPropertyBoolean("NamenParentObjekt3CB") == true) {
$ParentID = $this->ParentIDermitteln("ParentNr3NS", $InstanzID);
$ParentNameTabelle = $this->Umlaute_Ersetzen($this->ReadPropertyString("NameParentTabelle3TB"));
//.........这里部分代码省略.........
示例12: explode
if ($sleeptimer) {
$SleeptimerArray = explode(":", $sonos->GetSleeptimer());
$SleeptimerMinutes = $SleeptimerArray[0] * 60 + $SleeptimerArray[1];
if ($SleeptimerArray[2]) {
$SleeptimerMinutes = $SleeptimerMinutes + 1;
}
} else {
$SleeptimerMinutes = 0;
}
SetValueInteger(IPS_GetObjectIDByName("Sleeptimer", IPS_GetParent($_IPS["SELF"])), $SleeptimerMinutes);
}
}
$nowPlaying = GetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])));
if ($actuallyPlaying != $nowPlaying) {
SetValueString(IPS_GetObjectIDByName("nowPlaying", IPS_GetParent($_IPS["SELF"])), $actuallyPlaying);
}
}
// Set Group Volume
if (IPS_GetProperty(IPS_GetParent($_IPS["SELF"]), "GroupCoordinator")) {
$groupMembers = GetValueString(IPS_GetObjectIDByName("GroupMembers", IPS_GetParent($_IPS["SELF"])));
$groupMembersArray = array();
if ($groupMembers) {
$groupMembersArray = array_map("intval", explode(",", $groupMembers));
}
$groupMembersArray[] = IPS_GetParent($_IPS["SELF"]);
$GroupVolume = 0;
foreach ($groupMembersArray as $key => $ID) {
$GroupVolume += GetValueInteger(IPS_GetObjectIDByName("Volume", $ID));
}
SetValueInteger(IPS_GetObjectIDByName("GroupVolume", IPS_GetParent($_IPS["SELF"])), intval(round($GroupVolume / sizeof($groupMembersArray))));
}
示例13: SetValue
public function SetValue($key, $value) {
$stateId = IPS_GetObjectIDByIdent('STATE', $this->InstanceID);
$cmId = IPS_GetObjectIDByIdent('COLOR_MODE', $this->InstanceID);
$ctId = @IPS_GetObjectIDByIdent('COLOR_TEMPERATURE', $this->InstanceID);
$briId = IPS_GetObjectIDByIdent('BRIGHTNESS', $this->InstanceID);
$satId = @IPS_GetObjectIDByIdent('SATURATION', $this->InstanceID);
$hueId = @IPS_GetObjectIDByIdent('HUE', $this->InstanceID);
$colorId = @IPS_GetObjectIDByIdent('COLOR', $this->InstanceID);
$stateValue = GetValueBoolean($stateId);
$cmValue = $cmId ? GetValueInteger($cmId) : 0;
$ctValue = $ctId ? (500 - round(347 * GetValueInteger($ctId) / 100)) : 0;
$briValue = round(GetValueInteger($briId)*2.54);
$satValue = $satId ? round(GetValueInteger($satId)*2.54) : 0;
$hueValue = $hueId ? GetValueInteger($hueId) : 0;
$colorValue = $colorId ? GetValueInteger($colorId) : 0;
switch ($key) {
case 'STATE':
$stateNewValue = $value;
break;
case 'COLOR':
$colorNewValue = $value;
$stateNewValue = true;
$hex = str_pad(dechex($value), 6, 0, STR_PAD_LEFT);
$hsv = $this->HEX2HSV($hex);
SetValueInteger($colorId, $value);
$hueNewValue = $hsv['h'];
$briNewValue = $hsv['v'];
$satNewValue = $hsv['s'];
$cmNewValue = 0;
break;
case 'BRIGHTNESS':
$briNewValue = $value;
$stateNewValue = true;
if (IPS_GetProperty($this->InstanceID, 'LightFeatures') != 3) {
if ($cmValue == '0') {
$newHex = $this->HSV2HEX($hueValue, $satValue, $briNewValue);
SetValueInteger($colorId, hexdec($newHex));
$hueNewValue = $hueValue;
$satNewValue = $satValue;
} else {
$ctNewValue = $ctValue;
}
}
break;
case 'SATURATION':
$cmNewValue = 0;
$satNewValue = $value;
$stateNewValue = true;
$newHex = $this->HSV2HEX($hueValue, $satNewValue, $briValue);
SetValueInteger($colorId, hexdec($newHex));
$hueNewValue = $hueValue;
$briNewValue = $briValue;
break;
case 'COLOR_TEMPERATURE':
$cmNewValue = 1;
$ctNewValue = $value;
$briNewValue = $briValue;
break;
case 'COLOR_MODE':
$cmNewValue = $value;
$stateNewValue = true;
if ($cmNewValue == 1) {
$ctNewValue = $ctValue;
IPS_SetHidden($colorId, true);
IPS_SetHidden($ctId, false);
IPS_SetHidden($satId, true);
} else {
$hueNewValue = $hueValue;
$satNewValue = $satValue;
$briNewValue = $briValue;
$newHex = $this->HSV2HEX($hueValue, $satValue, $briValue);
SetValueInteger($colorId, hexdec($newHex));
IPS_SetHidden($colorId, false);
IPS_SetHidden($ctId, true);
IPS_SetHidden($satId, false);
}
break;
}
$changes = array();
if (isset($stateNewValue)) {
SetValueBoolean($stateId, $stateNewValue);
$changes['on'] = $stateNewValue;
}
if (isset($hueNewValue)) {
SetValueInteger($hueId, $hueNewValue);
$changes['hue'] = $hueNewValue;
}
if (isset($satNewValue)) {
SetValueInteger($satId, round($satNewValue * 100 / 254));
$changes['sat'] = $satNewValue;
}
if (isset($briNewValue)) {
SetValueInteger($briId, round($briNewValue * 100 / 254));
$changes['bri'] = $briNewValue;
}
if (isset($ctNewValue)) {
SetValueInteger($ctId, 100 - round(($ctNewValue - 153) * 100 / 347));
//.........这里部分代码省略.........
示例14: SendWSData
/**
* Forward weather data to WSDev instances
* Create one if needed
* @param $weather_data
*/
private function SendWSData($weather_data)
{
//parsing was OK, start distributing
$this->debug(__FUNCTION__, 'Prepare');
$class = __CLASS__;
$ts = $weather_data['date'];
$datum = date('Y-m-d H:i:s', $ts);
foreach ($this->sensors as $Device) {
if (!isset($weather_data[$Device])) {
continue;
}
$data = array();
$caps = '';
$id = $weather_data[$Device]['Id'];
$typ = $weather_data[$Device]['Typ'];
$data['Date'] = $datum;
foreach ($this->fieldlist as $cap) {
if (isset($weather_data[$Device][$cap])) {
$data[$cap] = $weather_data[$Device][$cap];
$caps .= ";" . $cap;
}
}
$this->debug(__FUNCTION__, "Sensor: {$id} Caps: {$caps} Prepared Data:" . print_r($data, true));
$found = false;
$instID = 0;
$instances = IPS_GetInstanceListByModuleID($this->module_interfaces['WSDEV']);
foreach ($instances as $instID) {
$I = @IPS_GetInstance($instID);
if ($I && $I['ConnectionID'] == $this->InstanceID) {
//my child
$iid = (string) IPS_GetProperty($instID, 'DeviceID');
$ityp = (string) IPS_GetProperty($instID, 'Typ');
$iclass = (string) IPS_GetProperty($instID, 'Class');
if ($iid == $Device && $ityp == $typ && $iclass == $class) {
$this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
$found = true;
break;
}
//if destdevice
}
//if
}
//for
if (!$found) {
//no free instance available, have to create a new one
if ($this->ReadPropertyBoolean('AutoCreate') == true) {
//new instance needed
$instID = $this->CreateWSDevice($data, $caps);
if ($instID > 0) {
//new instance needed
$this->debug(__FUNCTION__, 'CREATE Device with Caps: ' . $caps);
$found = true;
}
} else {
$this->debug(__FUNCTION__, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
IPS_LogMessage($class, 'Creating Device ID ' . $Device . ' disabled by Property AutoCreate');
}
//if autocreate
}
//if found
if ($found && $instID > 0) {
//send record to children
$json = json_encode(array("DataID" => $this->module_interfaces['WS-RX'], "DeviceID" => $Device, "Typ" => $typ, "Class" => $class, "WSData" => $data));
$this->debug(__FUNCTION__, $json);
@$this->SendDataToChildren($json);
$this->log_weather($data);
}
//found
}
//for
$this->debug(__FUNCTION__, 'Finished');
}
示例15: SendEnData
/**
* Forward data to EnergyDev instances
* Create one if needed
* @param array $data
* @param string $caps
*/
private function SendEnData($data, $caps)
{
//parsing was OK, start distributing
$this->debug(__FUNCTION__, 'Prepare');
$class = $data['Class'];
$id = $data['Id'];
$typ = $data['Typ'];
$found = false;
$instID = 0;
$instances = IPS_GetInstanceListByModuleID($this->module_interfaces['EnergyDev']);
foreach ($instances as $instID) {
$I = IPS_GetInstance($instID);
$iid = (string) IPS_GetProperty($instID, 'DeviceID');
$ityp = (string) IPS_GetProperty($instID, 'Typ');
$iclass = (string) IPS_GetProperty($instID, 'Class');
if ($I['ConnectionID'] == $this->InstanceID) {
//my child
if ($iid == $id && $iclass == $class && $ityp == $typ) {
$this->debug(__FUNCTION__, 'Use existing ID:' . $instID);
$found = true;
break;
}
//if destdevice
}
//if
}
//for
if (!$found) {
//no free instance available, have to create a new one
if ($this->ReadPropertyBoolean('AutoCreate') == true) {
//new instance needed
$this->debug(__FUNCTION__, 'CREATE NEW Device');
$instID = $this->CreateENDevice($data, $caps);
$found = true;
} else {
$this->debug(__FUNCTION__, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
IPS_LogMessage($class, 'Creating Device ID ' . $id . ' disabled by Property AutoCreate');
}
//if autocreate
}
//if found
//drop counterfactor from data
if (isset($data['CounterFactor'])) {
unset($data['CounterFactor']);
}
if ($found && $instID > 0) {
//send record to children
$json = json_encode(array("DataID" => $this->module_interfaces['EN-RX'], "DeviceID" => $data['Id'], "Typ" => $data['Typ'], "Class" => $class, "ENData" => $data));
$this->debug(__FUNCTION__, $json);
@$this->SendDataToChildren($json);
$datum = date('Y-m-d H:i:s', time());
$vid = @$this->GetIDForIdent('LastUpdate');
if ($vid) {
SetValueString($vid, $datum);
}
}
//found
}