From 092ee5edf010b78ef5a08658d6ce6039a53b86cb Mon Sep 17 00:00:00 2001 From: Heiko Wilknitz Date: Mon, 27 Nov 2023 10:17:59 +0100 Subject: [PATCH] Update v3.1.20231127 --- .style | 2 +- README.md | 32 ++++- {Twinkly_Device => TwinklyDevice}/form.json | 6 + {Twinkly_Device => TwinklyDevice}/locale.json | 6 +- {Twinkly_Device => TwinklyDevice}/module.json | 3 +- {Twinkly_Device => TwinklyDevice}/module.php | 122 +++++++++++++++- .../form.json | 0 .../locale.json | 2 +- .../module.json | 0 .../module.php | 0 library.json | 10 +- libs/ProfileHelper.php | 51 +------ libs/TwinklyHelper.php | 134 ++++++++++++------ libs/VariableHelper.php | 14 ++ libs/_traits.php | 2 +- 15 files changed, 276 insertions(+), 108 deletions(-) rename {Twinkly_Device => TwinklyDevice}/form.json (99%) rename {Twinkly_Device => TwinklyDevice}/locale.json (93%) rename {Twinkly_Device => TwinklyDevice}/module.json (82%) rename {Twinkly_Device => TwinklyDevice}/module.php (85%) rename {Twinkly_Discovery => TwinklyDiscovery}/form.json (100%) rename {Twinkly_Discovery => TwinklyDiscovery}/locale.json (94%) rename {Twinkly_Discovery => TwinklyDiscovery}/module.json (100%) rename {Twinkly_Discovery => TwinklyDiscovery}/module.php (100%) diff --git a/.style b/.style index ea67b89..c3da0b4 160000 --- a/.style +++ b/.style @@ -1 +1 @@ -Subproject commit ea67b8910400936a6445e27f40d7e60ca79dc069 +Subproject commit c3da0b498e05763595d29a223dbad7e9c12ce556 diff --git a/README.md b/README.md index e8710ac..0a6c629 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Twinkly [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) -[![Product](https://img.shields.io/badge/Symcon%20Version-6.0-blue.svg)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-3.0.20221201-orange.svg)](https://github.com/Wilkware/IPSymconTwinkly) +[![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg)](https://www.symcon.de/produkt/) +[![Version](https://img.shields.io/badge/Modul%20Version-3.1.20231127-orange.svg)](https://github.com/Wilkware/IPSymconTwinkly) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://github.com/Wilkware/IPSymconTwinkly/workflows/Check%20Style/badge.svg)](https://github.com/Wilkware/IPSymconTwinkly/actions) @@ -23,14 +23,14 @@ Ermöglicht die Kommunikation mit den Smart LED Lichterketten _Twinkly_. * Suchen und Erstellen von Twinkly Geräten (Discovery Modul) * Schalten des LED-Betriebsmodus (+ extended mode) -* Einstellen der Farbe, Helligkeit, Sättigung und Effekt +* Einstellen der Farbe, Helligkeit, Sättigung, Effekt und Film * Auslesen aller Geräte- und Netwerkinformationen * Auslesen der Firmware Version * Änderung des Gerätenamens ### 2. Voraussetzungen -* IP-Symcon ab Version 6.0 +* IP-Symcon ab Version 6.4 ### 3. Installation @@ -82,6 +82,7 @@ HELLIGKEIT | Über die Schaltflächen kann die aktuelle Helligkeit syncro SÄTTIGUNG | Über die Schaltflächen kann die aktuelle Sättigung syncronisiert werden (z.B. wenn von App geändert wurde). FARBE | Über die Schaltflächen kann die aktuelle Frabe syncronisiert werden (z.B. wenn von App geändert wurde). EFFEKT | Über die Schaltflächen kann der aktuelle Effekt syncronisiert werden. +FILM(E) | Über die Schaltflächen kann der aktuelle Film und alle hinterlegten Filme syncronisiert werden. GERÄTEINFOS | Über die Schaltflächen können die verschiedensten gerätespezifischen Einstellungen abgerufen werden. FIRMWARE | Über die Schaltflächen kann die Version des Gerätes ausgelesen und angezeigt werden. NETZWERKSTATUS | Über die Schaltflächen können die hinterlegten Netzwerkeinstellungen angezeigt werden. @@ -98,6 +99,7 @@ Schalter | Integer | Schalter (An/Aus) Modus | Integer | LED-Betriebsmodus Farbe | Integer | Farbwert Effekt | Integer | Effektauswahl (1..5) +Film | Integer | Filmauswahl (abhänig von in der APP hinterlegten Filmen/Effekten) Brightness | Integer | Helligkeitswert (0..100%) Sättigung | Integer | Sättigungswert (0..100%) @@ -109,6 +111,7 @@ Twinkly.Switch | Integer | LED-Betriebsmodus (0=Aus, 1=An) Twinkly.Mode | Integer | LED-Betriebsmodus (0=Color, 1=Effekt, 2=Film, 3=Demo) Twinkly.ModeEx | Integer | Extended LED-Betriebsmodus (0=Color, 1=Effekt, 2=Film, 3=Demo, 4=Music Reactive, 5=Playlist, 6=Echtzeit) Twinkly.Effect | Integer | Vordefinierte Effekte (1..5) +Twinkly.Movie | Integer | Hinterlegte Filme (-1 für keine; >0 für hinterlegte Filme) ### 6. WebFront @@ -132,7 +135,16 @@ void TWICKLY_Effect(int $InstanzID); Liest den aktuell am Gerät hinterlegten Effekt aus und synchronisert ihn mit der dazugehörigen Statusvariable. Die Funktion liefert als Rückgabewert einen String (Effekt: x (\)). -__Beispiel__: `TWICKLY_Brightness(12345);` Ausgabe "Helligkeit: 100%". +__Beispiel__: `TWICKLY_Effect(12345);` Ausgabe "Effekt: 1 (00000000-0000-0000-0000-000000000001)". + +```php +void TWICKLY_Movie(int $InstanzID); +``` + +Liest den aktuell am Gerät hinterlegten Film und und alle hinterlegten Filme aus und synchronisert ihn mit der dazugehörigen Statusvariable. +Die Funktion liefert als Rückgabewert einen String (Film: x (\)). + +__Beispiel__: `TWICKLY_Movie(12345);` Ausgabe "Film: 1 (Rainbow)". ```php void TWICKLY_Brightness(int $InstanzID); @@ -224,6 +236,16 @@ __Beispiel__: `TWICKLY_DeviceName(12345, 'Lichterkette');` Ausgabe "Der Name wur ### 8. Versionshistorie +v3.1.20231127 + +* _NEU_: Steuerung der Film(effekte) hinzugefügt +* _NEU_: Synchronisation der Statusvariablen erweitert (dynamisches Film-Profil) +* _NEU_: Twinkly-API erweitert +* _NEU_: Kompatibilität auf IPS 6.4 hoch gesetzt +* _FIX_: Interne Bibliotheken überarbeitet +* _FIX_: PHP Syle Check korrigiert +* _FIX_: Dokumentation überarbeitet + v3.0.20221201 * _NEU_: Trennung von Ein/Aus-Schaltung und Änderung des Betriebsmodus diff --git a/Twinkly_Device/form.json b/TwinklyDevice/form.json similarity index 99% rename from Twinkly_Device/form.json rename to TwinklyDevice/form.json index 416f499..ab3ea42 100644 --- a/Twinkly_Device/form.json +++ b/TwinklyDevice/form.json @@ -121,6 +121,12 @@ "caption": "EFFECT", "width": "150px", "onClick": "echo TWINKLY_Effect($id);" + }, + { + "type": "Button", + "caption": "MOVIE(S)", + "width": "150px", + "onClick": "echo TWINKLY_Movie($id);" } ] }, diff --git a/Twinkly_Device/locale.json b/TwinklyDevice/locale.json similarity index 93% rename from Twinkly_Device/locale.json rename to TwinklyDevice/locale.json index c3fa15f..64e1c35 100644 --- a/Twinkly_Device/locale.json +++ b/TwinklyDevice/locale.json @@ -27,6 +27,7 @@ "Name could not be changed!": "Name konnte nicht geändert werden!", "Name was changed successfully!": "Der Name wurde erfolgreich geändert!", "New device name:": "Neuer Gerätename:", + "No movies available!": "Keine Filme verfügbar!", "Device-Name": "Geräte-Name", "CHANGE": "ÄNDERN", "DEVICE INFO": "GERÄTEINFOS", @@ -36,13 +37,16 @@ "SATURATION": "SÄTTIGUNG", "COLOR": "FARBE", "EFFECT": "EFFEKT", + "MOVIE(S)": "FILM(E)", "Firmware: ": "Firmware: ", "Brightness: ": "Helligkeit: ", "Saturation: ": "Sättigung: ", "Color: ": "Farbe: ", "Effect: ": "Effekt: ", + "Movie: ": "Film: ", "Login error!": "Login Fehler!", "Error occurred!": "Fehler aufgetreten!", + "No films uploaded!": "Keine Filme hochgeladen!", "On": "An", "Off": "Aus", "Color": "Farbe", @@ -52,7 +56,7 @@ "Realtime": "Echtzeit", "Music Reactive": "Musik Reaktiv", "Source code, donation and licence ...": "Quellcode, Spende und Lizenz ...", - "The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommzerielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen." + "The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommerzielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen." } } } \ No newline at end of file diff --git a/Twinkly_Device/module.json b/TwinklyDevice/module.json similarity index 82% rename from Twinkly_Device/module.json rename to TwinklyDevice/module.json index bc1104e..710eb65 100644 --- a/Twinkly_Device/module.json +++ b/TwinklyDevice/module.json @@ -4,7 +4,8 @@ "type": 3, "vendor": "Ledworks", "aliases": [ - "Smart LED Lichterkette" + "Smart LED Lichterkette", + "Twinkly Lichterkette" ], "url": "https://wilkware.de/ip-symcon-module/twinkly", "parentRequirements": [], diff --git a/Twinkly_Device/module.php b/TwinklyDevice/module.php similarity index 85% rename from Twinkly_Device/module.php rename to TwinklyDevice/module.php index d049070..8ab1f73 100644 --- a/Twinkly_Device/module.php +++ b/TwinklyDevice/module.php @@ -65,6 +65,10 @@ class TwinklyDevice extends IPSModule [1, 'On', 'Light-100', 0x00FF00], ]; + private $assoMOVIE = [ + [-1, 'No movies available!', '', 0xFF0000], + ]; + public function Create() { //Never delete this line! @@ -83,23 +87,39 @@ public function Create() if (IPS_VariableProfileExists('Twinkly.Mode')) { IPS_DeleteVariableProfile('Twinkly.Mode'); // v2 => v3 migration check } - $this->RegisterProfile(VARIABLETYPE_INTEGER, 'Twinkly.Switch', 'Light', '', '', 0, 0, 0, 0, $this->assoSWITCH); - $this->RegisterProfile(VARIABLETYPE_INTEGER, 'Twinkly.Effect', 'Stars', '', '', 1, 5, 1, 0); - $this->RegisterProfile(VARIABLETYPE_INTEGER, 'Twinkly.Mode', 'Remote', '', '', 0, 0, 0, 0, $this->assoMODE); - $this->RegisterProfile(VARIABLETYPE_INTEGER, 'Twinkly.ModeEx', 'Remote', '', '', 0, 0, 0, 0, $this->assoMODEEX); + + // Statusvariablen (Movie) + $exists = @$this->GetIDForIdent('Movie'); + + // Profile anlegen + $this->RegisterProfileInteger('Twinkly.Switch', 'Light', '', '', 0, 0, 0, $this->assoSWITCH); + $this->RegisterProfileInteger('Twinkly.Effect', 'Stars', '', '', 1, 5, 1); + $this->RegisterProfileInteger('Twinkly.Mode', 'Remote', '', '', 0, 0, 0, $this->assoMODE); + $this->RegisterProfileInteger('Twinkly.ModeEx', 'Remote', '', '', 0, 0, 0, $this->assoMODEEX); + if (!IPS_VariableProfileExists('Twinkly.Movie')) { + $this->RegisterProfileInteger('Twinkly.Movie', 'Favorite', '', '', 0, 0, 0, $this->assoMOVIE); + } // Variablen erzeugen $this->RegisterVariableInteger('Switch', $this->Translate('Switch'), 'Twinkly.Switch', 0); $this->RegisterVariableInteger('Mode', $this->Translate('Mode'), 'Twinkly.Mode', 1); $this->RegisterVariableInteger('Color', $this->Translate('Color'), '~HexColor', 2); $this->RegisterVariableInteger('Effect', $this->Translate('Effect'), 'Twinkly.Effect', 3); - $this->RegisterVariableInteger('Brightness', $this->Translate('Brightness'), '~Intensity.100', 4); - $this->RegisterVariableInteger('Saturation', $this->Translate('Saturation'), '~Intensity.100', 5); + $this->RegisterVariableInteger('Movie', $this->Translate('Movie'), 'Twinkly.Movie', 4); + $this->RegisterVariableInteger('Brightness', $this->Translate('Brightness'), '~Intensity.100', 5); + $this->RegisterVariableInteger('Saturation', $this->Translate('Saturation'), '~Intensity.100', 6); + + // Initialwert setzen + if ($exists === false) { + $this->SetValueInteger('Movie', -1); + } + // Actions $this->EnableAction('Switch'); $this->EnableAction('Mode'); $this->EnableAction('Color'); $this->EnableAction('Effect'); + $this->EnableAction('Movie'); $this->EnableAction('Brightness'); $this->EnableAction('Saturation'); } @@ -193,6 +213,10 @@ public function RequestAction($ident, $value) $this->SetEffect($value); $this->SetValueInteger($ident, $value); break; + case 'Movie': + $this->SetMovie($value); + $this->SetValueInteger($ident, $value); + break; case 'Brightness': $this->SetBrightness($value); $this->SetValueInteger($ident, $value); @@ -319,6 +343,62 @@ public function Effect() return $this->Translate('Error occurred!'); } + /** + * 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:. + * + * TWICKLY_Movie($id); + */ + public function Movie() + { + if ($this->CheckLogin() === false) { + return $this->Translate('Login error!'); + } + // Debug + $this->SendDebug(__FUNCTION__, 'Obtain movie id.', 0); + // Host & Token + $host = $this->ReadPropertyString('Host'); + $token = $this->ReadAttributeString('Token'); + // Movie list + $json = $this->doMovies($host, $token); + if ($json !== false) { + $movies = []; + if (count($json['movies']) > 0) { + foreach ($json['movies'] as $movie) { + $movies[] = [$movie['id'], $movie['name'], '', 0xFF0000]; + } + } else { + $movies = $this->assoMOVIE; + } + // Delete VariableProfileAssociation + $old = IPS_GetVariableProfile('Twinkly.Movie')['Associations']; + $values = array_column($old, 'Value'); + foreach ($movies as $movie) { + IPS_SetVariableProfileAssociation('Twinkly.Movie', $movie[0], $this->Translate($movie[1]), $movie[2], $movie[3]); + $key = array_search($movie[0], $values); + if (!($key === false)) { + unset($values[$key]); + } + } + foreach ($values as $key => $value) { + IPS_SetVariableProfileAssociation('Twinkly.Movie', $value, '', '', 0); + } + } else { + return $this->Translate('Error occurred!'); + } + // Request + $json = $this->doMovie($host, $token); + $this->SendDebug(__FUNCTION__, $json); + // Sync brightness + if ($json !== false) { + $this->SetValueInteger('Movie', $json['id']); + // Display value + return $this->Translate('Movie: ') . ($json['id']) . ' (' . $json['name'] . ')'; + } + $this->SetValueInteger('Movie', -1); + return $this->Translate('No films uploaded!'); + } + /** * 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:. @@ -542,6 +622,36 @@ private function SetEffect(int $value) $this->doEffect($host, $token, $body); } + /** + * Sets the movie id. + * + * @param int $value Movie id. + */ + private function SetMovie(int $value) + { + if ($value < 0) { + $this->SendDebug(__FUNCTION__, 'No movie to set!'); + return; + } + + if ($this->CheckLogin() === false) { + $this->SendDebug(__FUNCTION__, 'Login error!'); + return; + } + // Debug + $this->SendDebug(__FUNCTION__, 'Set movieId to: ' . $value); + // Host + $host = $this->ReadPropertyString('Host'); + // Token + $token = $this->ReadAttributeString('Token'); + // Movie ID + $body = [ + 'id' => $value, + ]; + // Request + $this->doMovie($host, $token, $body); + } + /** * Sets the brightness level. * diff --git a/Twinkly_Discovery/form.json b/TwinklyDiscovery/form.json similarity index 100% rename from Twinkly_Discovery/form.json rename to TwinklyDiscovery/form.json diff --git a/Twinkly_Discovery/locale.json b/TwinklyDiscovery/locale.json similarity index 94% rename from Twinkly_Discovery/locale.json rename to TwinklyDiscovery/locale.json index 7c855ee..d3ae0ac 100644 --- a/Twinkly_Discovery/locale.json +++ b/TwinklyDiscovery/locale.json @@ -9,7 +9,7 @@ "Device name": "Gerätename", "Device state": "Gerätestatus", "Source code, donation and licence ...": "Quellcode, Spende und Lizenz ...", - "The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommzerielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen." + "The software is free of charge for non-commercial use, I would appreciate a donation if you like the module.": "Die Software ist für die nicht kommerzielle Nutzung kostenlos, über eine Spende bei Gefallen des Moduls würde ich mich sehr freuen." } } } \ No newline at end of file diff --git a/Twinkly_Discovery/module.json b/TwinklyDiscovery/module.json similarity index 100% rename from Twinkly_Discovery/module.json rename to TwinklyDiscovery/module.json diff --git a/Twinkly_Discovery/module.php b/TwinklyDiscovery/module.php similarity index 100% rename from Twinkly_Discovery/module.php rename to TwinklyDiscovery/module.php diff --git a/library.json b/library.json index 3508bd3..9bb964b 100644 --- a/library.json +++ b/library.json @@ -1,12 +1,12 @@ { "id": "{A00985FC-B2ED-5E9E-9BC6-A7A256C5F574}", - "name": "Twinkly", "author": "Wilkware (@Pitti)", "url": "https://wilkware.de", "compatibility": { - "version": "6.0" + "version": "6.4" }, - "version": "3.0", - "build": 20221201, - "date": 1669892400 + "name": "Twinkly", + "version": "3.1", + "build": 20231127, + "date": 1701082800 } \ No newline at end of file diff --git a/libs/ProfileHelper.php b/libs/ProfileHelper.php index f089f1b..1eebadf 100644 --- a/libs/ProfileHelper.php +++ b/libs/ProfileHelper.php @@ -19,42 +19,6 @@ */ trait ProfileHelper { - /** - * Create the profile for the given type, values and associations. - * - * @param string $vartype Type of the variable. - * @param string $name Profil name. - * @param string $icon Icon to display. - * @param string $prefix Variable prefix. - * @param string $suffix Variable suffix. - * @param int $minvalue Minimum value. - * @param int $maxvalue Maximum value. - * @param int $stepsize Increment. - * @param int $digits Decimal places. - * @param array $associations Associations of the values. - */ - protected function RegisterProfile($vartype, $name, $icon, $prefix = '', $suffix = '', $minvalue = 0, $maxvalue = 0, $stepsize = 0, $digits = 0, $associations = null) - { - if (!IPS_VariableProfileExists($name)) { - switch ($vartype) { - case VARIABLETYPE_BOOLEAN: - $this->RegisterProfileBoolean($name, $icon, $prefix, $suffix, $associations); - break; - case VARIABLETYPE_INTEGER: - $this->RegisterProfileInteger($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $digits, $associations); - break; - case VARIABLETYPE_FLOAT: - $this->RegisterProfileFloat($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $digits, $associations); - break; - case VARIABLETYPE_STRING: - $this->RegisterProfileString($name, $icon, $prefix, $suffix, $associations); - break; - } - } - - return $name; - } - /** * Create the profile for the given type with the passed name. * @@ -82,7 +46,7 @@ protected function RegisterProfileType($name, $vartype) * @param string $suffix Variable suffix. * @param array $asso Associations of the values. */ - protected function RegisterProfileBoolean($name, $icon, $prefix, $suffix, $asso) + protected function RegisterProfileBoolean($name, $icon, $prefix, $suffix, $asso = null) { $this->RegisterProfileType($name, VARIABLETYPE_BOOLEAN); @@ -106,21 +70,14 @@ protected function RegisterProfileBoolean($name, $icon, $prefix, $suffix, $asso) * @param int $minvalue Minimum value. * @param int $maxvalue Maximum value. * @param int $stepsize Increment. - * @param int $digits Decimal places. * @param array $asso Associations of the values. */ - protected function RegisterProfileInteger($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $digits, $asso) + protected function RegisterProfileInteger($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $asso = null) { $this->RegisterProfileType($name, VARIABLETYPE_INTEGER); IPS_SetVariableProfileIcon($name, $icon); IPS_SetVariableProfileText($name, $prefix, $suffix); - IPS_SetVariableProfileDigits($name, $digits); - - if (($asso !== null) && (count($asso) !== 0)) { - $minvalue = 0; - $maxvalue = 0; - } IPS_SetVariableProfileValues($name, $minvalue, $maxvalue, $stepsize); if (($asso !== null) && (count($asso) !== 0)) { @@ -143,7 +100,7 @@ protected function RegisterProfileInteger($name, $icon, $prefix, $suffix, $minva * @param int $digits Decimal places. * @param array $asso Associations of the values. */ - protected function RegisterProfileFloat($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $digits, $asso) + protected function RegisterProfileFloat($name, $icon, $prefix, $suffix, $minvalue, $maxvalue, $stepsize, $digits, $asso = null) { $this->RegisterProfileType($name, VARIABLETYPE_FLOAT); @@ -173,7 +130,7 @@ protected function RegisterProfileFloat($name, $icon, $prefix, $suffix, $minvalu * @param string $suffix Variable suffix. * @param array $asso Associations of the values. */ - protected function RegisterProfileString($name, $icon, $prefix, $suffix, $asso) + protected function RegisterProfileString($name, $icon, $prefix, $suffix, $asso = null) { $this->RegisterProfileType($name, VARIABLETYPE_STRING); diff --git a/libs/TwinklyHelper.php b/libs/TwinklyHelper.php index 9eae5a3..8ecdab1 100644 --- a/libs/TwinklyHelper.php +++ b/libs/TwinklyHelper.php @@ -65,46 +65,6 @@ */ trait TwinklyHelper { - /** - * doEffect - Get/Set current LED effect - * - * HTTP request - * GET /xled/v1/led/effects/current - * - * The response will be an object: - * code - (integer), application return code. - * unique_id - (string), UUID. Since firmware version 2.5.6. - * effect_id - (integer), e.g. 0 - * - * HTTP request - * POST /xled/v1/led/effects/current - * - * Parameters as JSON object: - * effect_id - (int), id of effect, e.g. 0. - * - * The response will be an object: - * code - Application return code. - */ - private function doEffect($ip, $token, $body = null) - { - return $this->doAPI($ip, $token, 'led/effects/current', $body); - } - - /** - * doEffects - Get number of LED effects - * - * HTTP request - * GET /xled/v1/led/effects - * - * The response will be an object: - * effects_number - (integer), e.g. 5 - * unique_ids - (array) of guid's. e.g. 00000000-0000-0000-0000-000000000001 - * code - Application return code. - */ - private function doEffects($ip, $token) - { - return $this->doAPI($ip, $token, 'led/effects', null); - } /** * doLogin - Request access token. * @@ -272,6 +232,100 @@ private function doName($ip, $token, $body = null) return $this->doAPI($ip, $token, 'device_name', $body); } + /** + * doEffect - Get/Set current LED effect + * + * HTTP request + * GET /xled/v1/led/effects/current + * + * The response will be an object: + * code - (integer), application return code. + * unique_id - (string), UUID. Since firmware version 2.5.6. + * effect_id - (integer), e.g. 0 + * + * HTTP request + * POST /xled/v1/led/effects/current + * + * Parameters as JSON object: + * effect_id - (int), id of effect, e.g. 0. + * + * The response will be an object: + * code - Application return code. + */ + private function doEffect($ip, $token, $body = null) + { + return $this->doAPI($ip, $token, 'led/effects/current', $body); + } + + /** + * doEffects - Get number of LED effects + * + * HTTP request + * GET /xled/v1/led/effects + * + * The response will be an object: + * effects_number - (integer), e.g. 5 + * unique_ids - (array) of guid's. e.g. 00000000-0000-0000-0000-000000000001 + * code - Application return code. + */ + private function doEffects($ip, $token) + { + return $this->doAPI($ip, $token, 'led/effects', null); + } + + /** + * doMovie - Gets/Sets the id of the movie shown when in movie mode. + * + * HTTP request + * GET /xled/v1/led/movies/current + * + * The response will be an object. + * code - (integer), application return code. + * id - (integer), numeric id of movie, in range 0 .. 15 + * unique_id - (string), UUID of movie. + * name - (string), name of movie. + * + * HTTP request + * POST /xled/v1/led/movies/current + * + * Parameters as JSON object. + * id - (int), id of movie, in range 0 .. 15. + * + * The response will be an object. + * code - (integer), application return code. + * + */ + private function doMovie($ip, $token, $body = null) + { + return $this->doAPI($ip, $token, 'movies/current', $body); + } + + /** + * doMovies - Get list of movies + * + * HTTP request + * GET /xled/v1/movies + * + * The response will be an object. + * code - Application return code. + * movies - Array of objects + * available_frames- (integer), e.g. 992 + * max_capacity - (integer), e.g. 992 + * + * Where each item of movies is an object. + * id - (integer), e.g. 0 + * name - (string) + * unique_id - (string) UUID + * descriptor_type - (string), e.g “rgbw_raw” for firmware family “G” or “rgb_raw” for firmware family “F” + * leds_per_frame - (integer), e.g. 210 + * frames_number - (integer), e.g. 4 + * fps - (integer), e.g. 0 + */ + private function doMovies($ip, $token) + { + return $this->doAPI($ip, $token, 'movies', null); + } + /** * doMode - Get/Set LED operation mode. * diff --git a/libs/VariableHelper.php b/libs/VariableHelper.php index 5de352e..b7d4b54 100644 --- a/libs/VariableHelper.php +++ b/libs/VariableHelper.php @@ -60,4 +60,18 @@ protected function SetValueInteger(string $ident, int $value) SetValueInteger($id, $value); } } + + /** + * Sets the variable inactive. + * + * @param string $ident Ident of the integer variable + * @param bool $value Enable or disable value the variable + */ + private function SetVariableDisabled(string $ident, bool $value) + { + $id = @$this->GetIDForIdent($ident); + if ($id !== false) { + IPS_SetDisabled($id, $value); + } + } } diff --git a/libs/_traits.php b/libs/_traits.php index 382cda2..6ba9a42 100644 --- a/libs/_traits.php +++ b/libs/_traits.php @@ -171,7 +171,7 @@ define('IS_ACTIVE', IS_SBASE + 2); //module created and running define('IS_DELETING', IS_SBASE + 3); //module us being deleted define('IS_INACTIVE', IS_SBASE + 4); //module is not beeing used -// --- ERROR CODES + // --- ERROR CODES define('IS_EBASE', 200); //default errorcode define('IS_NOTCREATED', IS_EBASE + 1); //instance could not be created }