Add files via upload
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"elements":
|
||||
[
|
||||
{ "type": "SelectCategory", "name": "PropertyCategoryID", "caption": "Target" },
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameBool", "caption": "Profil - Bool" , "profileType": 0},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameInt", "caption": "Profil - Integer" , "profileType": 1},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameFloat", "caption": "Profil - Float" , "profileType": 2},
|
||||
{ "type": "SelectProfile", "name": "PropertyProfileNameString", "caption": "Profil - String" , "profileType": 3}
|
||||
],
|
||||
"actions":
|
||||
[
|
||||
|
||||
{ "type": "Button", "label": "Set selected Profiles", "onClick": "VTPS_setProfile($id);" }
|
||||
],
|
||||
"status":
|
||||
[
|
||||
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"id": "{74DEF544-0497-69C8-9802-00F641E279D9}",
|
||||
"name": "ProfileSetter",
|
||||
"type": 3,
|
||||
"vendor": "J.H. Artworks",
|
||||
"aliases":
|
||||
[
|
||||
],
|
||||
"url": "https://jh-artworks.com",
|
||||
"parentRequirements": [],
|
||||
"childRequirements": [],
|
||||
"implemented": [],
|
||||
"prefix": "VTPS"
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?
|
||||
// Klassendefinition
|
||||
class ProfileSetter extends IPSModule {
|
||||
// Überschreibt die interne IPS_Create($id) Funktion
|
||||
public function Create() {
|
||||
// Diese Zeile nicht löschen.
|
||||
parent::Create();
|
||||
|
||||
$this->RegisterPropertyInteger("PropertyCategoryID",0);
|
||||
$this->RegisterPropertyString("PropertyProfileNameBool","~Switch");
|
||||
$this->RegisterPropertyString("PropertyProfileNameInt","~Intensity.100");
|
||||
$this->RegisterPropertyString("PropertyProfileNameFloat","~Temperature");
|
||||
$this->RegisterPropertyString("PropertyProfileNameString","~TextBox");
|
||||
|
||||
}
|
||||
|
||||
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
||||
public function ApplyChanges() {
|
||||
// Diese Zeile nicht löschen
|
||||
parent::ApplyChanges();
|
||||
}
|
||||
/**
|
||||
* Die folgenden Funktionen stehen automatisch zur Verfügung, wenn das Modul über die "Module Control" eingefügt wurden.
|
||||
* Die Funktionen werden, mit dem selbst eingerichteten Prefix, in PHP und JSON-RPC wiefolgt zur Verfügung gestellt:
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function setProfile() {
|
||||
|
||||
$idKat = $this->ReadPropertyInteger("PropertyCategoryID");
|
||||
$katChilds = IPS_GetChildrenIDs($idKat);
|
||||
|
||||
foreach ($katChilds as $katChild) {
|
||||
$chilid = IPS_GetChildrenIDs($katChild)[0];
|
||||
$parentname = IPS_GetName($katChild);
|
||||
|
||||
$payload = GetValue($chilid);
|
||||
// determine data type
|
||||
if(is_string($payload)) {
|
||||
$ips_var_type = 3;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameString");
|
||||
} else if(is_float($payload)) {
|
||||
$ips_var_type = 2;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameFloat");
|
||||
} else if(is_int($payload)) {
|
||||
$ips_var_type = 1;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameInt");
|
||||
} else if(is_bool($payload)) {
|
||||
$ips_var_type = 0;
|
||||
$profile = $this->ReadPropertyString("PropertyProfileNameBool");
|
||||
} else { // unsupported
|
||||
return false;
|
||||
}
|
||||
|
||||
IPS_SetVariableCustomProfile($chilid, $profile);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user