Skip to content

Commit

Permalink
Update v3.1.20231127
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilkware committed Nov 27, 2023
1 parent 0ca01bf commit 092ee5e
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .style
Submodule .style updated 4 files
+28 −36 .php-cs-fixer.php
+13 −13 .php-json-fixer.php
+0 −183 .php_cs
+1 −10 README.md
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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%)

Expand All @@ -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

Expand All @@ -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 (\<uuid\>)).

__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 (\<name\>)).

__Beispiel__: `TWICKLY_Movie(12345);` Ausgabe "Film: 1 (Rainbow)".

```php
void TWICKLY_Brightness(int $InstanzID);
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Twinkly_Device/form.json → TwinklyDevice/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -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);"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion Twinkly_Device/locale.json → TwinklyDevice/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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."
}
}
}
3 changes: 2 additions & 1 deletion Twinkly_Device/module.json → TwinklyDevice/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
122 changes: 116 additions & 6 deletions Twinkly_Device/module.php → TwinklyDevice/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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');
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:.
Expand Down Expand Up @@ -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.
*
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions library.json
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit 092ee5e

Please sign in to comment.