Skip to content

Commit

Permalink
Update v1.1.20240224
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilkware committed Feb 24, 2024
1 parent b0448c7 commit 1245c2e
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .style
Submodule .style updated 1 files
+27 −33 .php-cs-fixer.php
10 changes: 10 additions & 0 deletions Color Loop/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@
"type": "CheckBox",
"name": "CheckColor",
"caption": "Create variables for selection of start color per luminaire?"
},
{
"type": "CheckBox",
"name": "CheckActive",
"caption": "Activate color loop automatically when the device is switched on?"
},
{
"type": "CheckBox",
"name": "CheckContinue",
"caption": "Continue color loop with last color values?"
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions Color Loop/locale.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"translations": {
"de": {
"Color Loop": "Farbverlauf",
"\nColor Loop\n ": "\nFarbverlauf\n ",
"The module offers the possibility to activate an automatic colour gradient or a colour change.": "Das Modul bietet die Möglichkeit, einen automatischen Farbverlauf bzw. einen Farbwechsel zu aktivieren.",
"Circuit ...": "Schaltung ...",
Expand All @@ -18,6 +19,8 @@
"Advanced settings ...": "Erweiterte Einstellungen ...",
"Create variables for selection of start color per luminaire?": "Variablen für Auswahl der Startfarbe pro Leuchte anlegen?",
"In addition, create a normal switch variable to temporarily switch the colour loop on or off (e.g. for webfront)?": "Zusätzlich noch eine normale Schaltervariable anlegen zum temporären An- bzw. Ausschalten der Farbschleife (z.B. für Webfront)?",
"Continue color loop with last color values?": "Farbschleife mit den letzten Farbwerten fortsetzen?",
"Activate color loop automatically when the device is switched on?": "Farbschleife beim Einschalten des Geräts automatisch aktivieren?",
"Transition": "Übergang",
"Increment": "Schrittweite",
"Fast": "Schnell",
Expand Down
9 changes: 3 additions & 6 deletions Color Loop/module.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"id": "{67B80A2C-0E39-B6B3-E767-86E6C9AE653C}",
"name": "Color Loop",
"url": "https://wilkware.de/ip-symconmodule/farbverlauf",
"type": 3,
"vendor": "",
"aliases": [
"ColorLoop",
"Farbverlauf"
],
"aliases": [],
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
"prefix": "WWXCL",
"url": "https://github.com/Wilkware/IPSymconColorLoop"
"prefix": "WWXCL"
}
22 changes: 18 additions & 4 deletions Color Loop/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public function Create()
$this->RegisterPropertyString('ColorVariables', '[]');
// Settings
$this->RegisterPropertyBoolean('CheckColor', false);
$this->RegisterPropertyBoolean('CheckActive', false);
$this->RegisterPropertyBoolean('CheckContinue', false);
// Profiles
$this->RegisterProfile(VARIABLETYPE_INTEGER, 'WWXCL.Increment', 'Speedo', '', '', 5, 355, 5, 0);
$this->RegisterProfile(VARIABLETYPE_INTEGER, 'WWXCL.Transition', 'Repeat', '', '', 0, 0, 0, 0, $this->assoTransition);
$this->RegisterProfileInteger('WWXCL.Increment', 'Speedo', '', '', 5, 355, 5);
$this->RegisterProfileInteger('WWXCL.Transition', 'Repeat', '', '', 0, 0, 0, $this->assoTransition);
// Status variable (active)
$exists = @$this->GetIDForIdent('active');
$this->RegisterVariableBoolean('active', $this->Translate('Active'), '~Switch', 0);
Expand Down Expand Up @@ -258,8 +260,14 @@ private function Active($value)
private function Switch($value)
{
$this->SendDebug(__FUNCTION__, ($value ? 'true' : 'false'));
$cact = $this->ReadPropertyBoolean('CheckActive');
$ccon = $this->ReadPropertyBoolean('CheckContinue');
if($value) { // ON
$ison = $this->GetValue('active');
if($cact && !$ison) {
$ison = true;
$this->SetValueBoolean('active', $ison);
}
// only if color loop is active switched!
if($ison) {
$tran = $this->GetValue('transition');
Expand All @@ -283,13 +291,19 @@ private function Switch($value)
$data[] = [$varid, $color];
}
$this->SendDebug(__FUNCTION__, 'Data: ' . print_r($data, true), 0);
$this->SetBuffer('loop_data', serialize($data));
$buffer = $this->GetBuffer('loop_data');
if(!$ccon || empty($buffer)) {
$this->SetBuffer('loop_data', serialize($data));
}
// Start Timer
$this->SetTimerInterval('ColorLoopTrigger', $tran * 1000);
}
} else { // OFF
$this->SetTimerInterval('ColorLoopTrigger', 0);
$this->SetBuffer('loop_data', '');
// continue with the last colors?
if(!$ccon) {
$this->SetBuffer('loop_data', '');
}
}
}

Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Farbeverlauf (Color Loop)

[![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%20%3E-blue.svg)](https://www.symcon.de/produkt/)
[![Version](https://img.shields.io/badge/Modul%20Version-1.0.20230728-orange.svg)](https://github.com/Wilkware/IPSymconColorLoop)
[![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/IPSymconColorLoop/workflows/Check%20Style/badge.svg)](https://github.com/Wilkware/IPSymconColorLoop/actions)
[![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/)
[![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/)
[![Version](https://img.shields.io/badge/Modul%20Version-1.0.20230728-orange.svg?style=flat-square)](https://github.com/Wilkware/IPSymconColorLoop)
[![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
[![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/IPSymconColorLoop/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/IPSymconColorLoop/actions)

Das Modul bietet die Möglichkeit, einen automatischen Farbverlauf bzw. einen Farbwechsel zu aktivieren. Sobald er aktiviert ist, läuft eine kontinuierliche Schleife durch verschiedene Farben, die sich fortlaufend wiederholt.

Expand Down Expand Up @@ -37,7 +37,7 @@ Gute Effekte kann man erzielen bei kleiner Schrittweite (5) und einem sehr langs

### 2. Voraussetzungen

* IP-Symcon ab Version 6.0
* IP-Symcon ab Version 6.4
* Getestet mit Philips Hue Color Ambiance Leuchtmitteln

### 3. Installation
Expand Down Expand Up @@ -65,9 +65,9 @@ Schaltervariable | Die Schaltvariable, welche als Indikator für
Name | Beschreibung
------------------------------- | -----------------------------------------------------------------
Leuchtgruppe (Liste) | Alle Geräte, welche an der Farbschleife beteiligt seien sollen
|- Statusvariable | Statusvariable des Leuchtmittels, welche die Farbe abbildet. Muss sich über RequestAction steuern lassen und das Profil _~HexColor_ besitzen.
|- Startfarbe | Farbwert mit dem die Farbschleife beginnen soll. Die Farbauswahl 'Transparent' bewirkt die Verwendung des aktuell eingestellten Farbcodes des Leuchtmittels als Startfarbe.
|- Leuchtenname | Der Leuchtenname ist nur notwendig wenn man die Startfarbe auch über das WebFront ändern möchte (Statusvariable).
-- Statusvariable | Statusvariable des Leuchtmittels, welche die Farbe abbildet. Muss sich über RequestAction steuern lassen und das Profil _~HexColor_ besitzen.
-- Startfarbe | Farbwert mit dem die Farbschleife beginnen soll. Die Farbauswahl 'Transparent' bewirkt die Verwendung des aktuell eingestellten Farbcodes des Leuchtmittels als Startfarbe.
-- Leuchtenname | Der Leuchtenname ist nur notwendig wenn man die Startfarbe auch über das WebFront ändern möchte (Statusvariable).

> Erweiterte Einstellungen ...
Expand All @@ -84,7 +84,7 @@ Name | Typ | Beschreibung
Aktiv | Boolean | Schalter für Aktivierung oder Deaktivierung der Farbschleife, d.h. soll Farbschleife starten wenn Leuchtgruppe angeschaltet wird.
Schrittweite | Integer | Auswahl, wie groß die Farbänderungsschritte erfolgen soll (in 5er Schritten zwischen 5 und 355).
Übergang | String | Auswahl, wie schnell der einzelne Farbwechsel erfolgen soll.
[Leuchtenname] | Integer | Aktivierbar über die erweiterten Einstellungen. Startfarbe fürs WebFront.
\[Leuchtenname\] | Integer | Aktivierbar über die erweiterten Einstellungen. Startfarbe fürs WebFront.

Folgendes Profil wird angelegt:

Expand All @@ -103,6 +103,13 @@ Das Modul stellt keine direkten Funktionsaufrufe zur Verfügung.

### 8. Versionshistorie

v1.1.20240224

* _NEU_: Farbschleife kann automatisch mit Gerät eingeschaltet werden
* _NEU_: Farbschleife kann bei Wiedereinschalten auf letzte Farbwerte aufsetzen
* _FIX_: Interne Bibliotheken überarbeitet
* _FIX_: Internes Deployment überarbeitet

v1.0.20230728

* _NEU_: Initialversion
Expand Down
8 changes: 4 additions & 4 deletions library.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"author": "Wilkware (@Pitti)",
"url": "https://wilkware.de",
"compatibility": {
"version": "6.0"
"version": "6.4"
},
"version": "1.0",
"build": 20230728,
"date": 1690538400
"version": "1.1",
"build": 20230224,
"date": 1708772400
}
59 changes: 6 additions & 53 deletions libs/ProfileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);

Expand All @@ -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)) {
Expand All @@ -143,19 +100,14 @@ 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);

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);
IPS_SetVariableProfileDigits($name, $digits);

if (($asso !== null) && (count($asso) !== 0)) {
foreach ($asso as $ass) {
Expand All @@ -177,8 +129,9 @@ protected function RegisterProfileString($name, $icon, $prefix, $suffix, $asso)
{
$this->RegisterProfileType($name, VARIABLETYPE_STRING);

IPS_SetVariableProfileText($name, $prefix, $suffix);
IPS_SetVariableProfileIcon($name, $icon);
IPS_SetVariableProfileText($name, $prefix, $suffix);

if (($asso !== null) && (count($asso) !== 0)) {
foreach ($asso as $ass) {
IPS_SetVariableProfileAssociation($name, $ass[0], $this->Translate($ass[1]), $ass[2], $ass[3]);
Expand Down
Loading

0 comments on commit 1245c2e

Please sign in to comment.