Skip to content

Commit

Permalink
Merge pull request #111 from patrickbs96/different_mode_on_per_light
Browse files Browse the repository at this point in the history
Different mode on per light #50
  • Loading branch information
patrickbs96 authored Jan 2, 2022
2 parents 791cbf3 + cd670d3 commit 2950981
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 patrickbs96 <[email protected]>
Copyright (c) 2022 patrickbs96 <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ The following Settings are available:

In the table you can add all the Twinkly lights you want to control.

| Column | Description |
|--------------|------------------------------------|
| `Enabled` | Shall this connection be accessed |
| `Name` | Name of the connection in ioBroker |
| `IP Address` | IP-Address to the Twinkly Lights |
| Column | Description |
|--------------|----------------------------------------------------------------|
| `Enabled` | Shall this connection be accessed |
| `Name` | Name of the connection in ioBroker |
| `IP Address` | IP-Address to the Twinkly Lights |
| `State On` | Which `ledMode` should be activated when state `on` is enabled |

The following additionals States are created per device when checked:
* Device Info
Expand All @@ -46,7 +47,7 @@ The following States are available:
| `details` | :x: | Device Details |
| `firmware` | :x: | Firmware Version |
| `ledBri` | :heavy_check_mark: | Brightness (deactivate control with -1) |
| `ledColor` | :heavy_check_mark: | Color of LEDs, HSV/RGB(W)/HEX |
| `ledColor` | :heavy_check_mark: | Color of LEDs, HSV/RGB(W)/HEX (`Color`) |
| `ledConfig` | :heavy_check_mark: | Configuration of LEDs |
| `ledEffect` | :heavy_check_mark: | Effects (`Effect`) |
| `ledLayout` | :heavy_check_mark: | Layout of LEDs (disabled for further testing) |
Expand All @@ -72,6 +73,9 @@ The following States are available:

## Changelog

### 0.2.11 (2022-01-02)
* (patrickbs96) Add setting to select which ledMode should be activated

### 0.2.10 (2021-12-31)
* (patrickbs96) Add setting to enable automatically switching of Mode after State change (color, effect, movie, playlist)

Expand Down Expand Up @@ -135,7 +139,7 @@ The following States are available:
## License
MIT License

Copyright (c) 2021 patrickbs96 <[email protected]>
Copyright (c) 2022 patrickbs96 <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 12 additions & 12 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@
for (let i = 0; i < devices.length; i++) {
if (devices[i].enabled === undefined)
devices[i].enabled = true;
if (devices[i].stateOn === undefined)
devices[i].stateOn = 'movie';
}

for (const key in settings) {
if (!settings.hasOwnProperty(key)) continue;

const $value = $('#' + key + '.value');
if ($value.attr('type') === 'checkbox') {
$value.prop('checked', settings[key]).on('change', function() {
onChange();
});
$value.prop('checked', settings[key])
.on('change', onChange);
} else {
$value.val(settings[key]).on('change', function() {
onChange();
}).keyup(function() {
onChange();
});
$value.val(settings[key])
.on('change', onChange)
.keyup(onChange);
}
}

Expand Down Expand Up @@ -107,12 +106,13 @@
<div class="col s12 m8" id="devices">
<a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a>
<div class="table-values-div">
<table class="table-values">
<table class="table-values" id="deviceList">
<thead>
<tr>
<th data-name="enabled" class="translate" style="width: 100px" data-style="width: 80px" data-type="checkbox">Enabled</th>
<th data-name="name" class="translate">Name</th>
<th data-name="host" class="translate" style="width: 30%; white-space: nowrap" >IP Address</th>
<th data-name="enabled" class="translate" data-style="width: 80px" data-type="checkbox">Enabled</th>
<th data-name="name" class="translate">Name</th>
<th data-name="host" class="translate">IP Address</th>
<th data-name="stateOn" class="translate" data-style="width: 200px" data-type="select" data-options="color/Color;effect/Effect;movie/Movie;playlist/Playlist">State On</th>
<th data-buttons="delete" style="width: 120px"></th>
</tr>
</thead>
Expand Down
60 changes: 60 additions & 0 deletions admin/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,65 @@ systemDictionary = {
'es': 'Cambiar de modo después del cambio de estado',
'pl': 'Przełącz tryb po zmianie stanu',
'zh-cn': '状态改变后切换模式'
},
'State On': {
'en': 'State On',
'de': 'Status an',
'ru': 'Состояние включено',
'pt': 'Estado Ligado',
'nl': 'Staat Aan',
'fr': 'État activé',
'it': 'Stato attivo',
'es': 'Estado encendido',
'pl': 'Stan włączony',
'zh-cn': '状态开启'
},
'Color': {
'en': 'Color',
'de': 'Farbe',
'ru': 'Цвет',
'pt': 'Cor',
'nl': 'Kleur',
'fr': 'Couleur',
'it': 'Colore',
'es': 'Color',
'pl': 'Kolor',
'zh-cn': '颜色'
},
'Effect': {
'en': 'Effect',
'de': 'Effekt',
'ru': 'Эффект',
'pt': 'Efeito',
'nl': 'Effect',
'fr': 'Effet',
'it': 'Effetto',
'es': 'Efecto',
'pl': 'Efekt',
'zh-cn': '影响'
},
'Movie': {
'en': 'Movie',
'de': 'Film',
'ru': 'Кино',
'pt': 'Filme',
'nl': 'Film',
'fr': 'Film',
'it': 'Film',
'es': 'Película',
'pl': 'Film',
'zh-cn': '电影'
},
'Playlist': {
'en': 'Playlist',
'de': 'Wiedergabeliste',
'ru': 'Плейлист',
'pt': 'Lista de reprodução',
'nl': 'afspeellijst',
'fr': 'Playlist',
'it': 'elenco di riproduzione',
'es': 'Lista de reproducción',
'pl': 'Lista odtwarzania',
'zh-cn': '播放列表'
}
};
Binary file modified img/admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "twinkly",
"version": "0.2.10",
"version": "0.2.11",
"news": {
"0.2.11": {
"en": "Add setting to select which ledMode should be activated",
"de": "Einstellung hinzufügen, um auszuwählen, welcher LEDMode aktiviert werden soll",
"ru": "Добавьте настройку, чтобы выбрать, какой ledMode должен быть активирован",
"pt": "Adicionar configuração para selecionar qual ledMode deve ser ativado",
"nl": "Instelling toevoegen om te selecteren welke ledMode moet worden geactiveerd",
"fr": "Ajouter un paramètre pour sélectionner quel ledMode doit être activé",
"it": "Aggiungi impostazione per selezionare quale ledMode deve essere attivato",
"es": "Agregar configuración para seleccionar qué ledMode debe activarse",
"pl": "Dodaj ustawienie, aby wybrać, który tryb led powinien być aktywowany",
"zh-cn": "添加设置以选择应激活哪个 ledMode"
},
"0.2.10": {
"en": "Add setting to enable automatic switching Mode after State change (color, effect, movie, playlist)",
"de": "Einstellung hinzufügen, um den automatischen Wechselmodus nach Statusänderung zu aktivieren (color, effect, movie, playlist)",
Expand Down
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let pollingInterval = null;

/**
* Twinkly-Verbindungen
* @type {{[x: string]: {enabled: Boolean, paused: Boolean, name: String, host: String, connected: Boolean, twinkly: Twinkly}}}
* @type {{[x: string]: {enabled: Boolean, paused: Boolean, name: String, host: String, stateOn: String, connected: Boolean, twinkly: Twinkly}}}
*/
const connections = {};

Expand Down Expand Up @@ -605,7 +605,7 @@ function startAdapter(options) {
// Gerät ein-/ausschalten
} else if (!group && command === stateNames.on.id) {
try {
await connection.twinkly.setLEDMode(state.val ? twinkly.lightModes.value.movie : twinkly.lightModes.value.off);
await connection.twinkly.setLEDMode(state.val ? connection.stateOn : twinkly.lightModes.value.off);
} catch (e) {
adapter.log.error(`[${connectionName}.${command}] Could not set ${state.val}! ${e.message}`);
}
Expand Down Expand Up @@ -1065,6 +1065,7 @@ async function syncConfig() {
paused : false,
name : deviceName,
host : device.host,
stateOn : device.stateOn && Object.keys(twinkly.lightModes.value).includes(device.stateOn) ? device.stateOn : twinkly.lightModes.value.movie,
connected : false,
twinkly : new twinkly.Twinkly(adapter, deviceName, device.host, handleSentryMessage)
};
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.twinkly",
"version": "0.2.10",
"version": "0.2.11",
"description": "Adapter to communicate with the Twinkly lights.",
"author": {
"name": "patrickbs96",
Expand Down

0 comments on commit 2950981

Please sign in to comment.