Skip to content

Commit

Permalink
HmIP-MP3P Sounds (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Feb 15, 2019
1 parent 38d2b91 commit aa9106d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
53 changes: 47 additions & 6 deletions nodes/ccu-signal.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,21 @@
'20s': 12,
'40s': 13,
'60s': 14,
'Permanent': 15,
Permanent: 15
};


const ccuSound = {
'Interner Sound': 0
};

for (let i = 1; i < 253; i++) {
ccuSound['Datei ' + ('00' + i).slice(-3)] = i;
}

ccuSound['Zufällig'] = 253;
ccuSound.Vorherig = 254;
ccuSound.Egal = 255;

RED.nodes.registerType('ccu-signal', {

category: 'ccu',
Expand Down Expand Up @@ -75,6 +87,7 @@
repetitions: {value: 0},
dimmer_level: {value: 100},
dimmer_list: {value: []},
sound_level: {value: 50},
sound_list: {value: []},
acoustic_level: {value: 50},
optical_alarm_selection: {value: 'DISABLE_OPTICAL_SIGNAL'},
Expand Down Expand Up @@ -243,7 +256,6 @@
$('<option value="' + ccuSignalColors[name] + '"' + (ccuSignalColors[name] === parseInt(data.cmd, 10) ? ' selected' : '') +
'>' + name + '</option>').appendTo(select);
});

}
});

Expand All @@ -269,6 +281,23 @@
}
});

$('#node-input-acoustic-container').css('min-height', '300px').css('min-width', '450px').editableList({
sortable: true,
removable: true,
addItem: (container, i, data) => {
if ($('#node-input-acoustic-container').editableList('length') > 12) {
$('#node-input-acoustic-container').editableList('removeItem', data);
return false;
}

const select = $('<select class="number sound" value="' + data.sound + '"/>').appendTo(container);
Object.keys(ccuSound).forEach(name => {
$('<option value="' + ccuSound[name] + '"' + (ccuSound[name] === parseInt(data.sound, 10) ? ' selected' : '') +
'>' + name + '</option>').appendTo(select);
});
}
});

$('#node-input-key-container').css('min-height', '300px').css('min-width', '450px').editableList({});

if (this.channelType === 'SIGNAL_CHIME') {
Expand All @@ -289,6 +318,10 @@
});
} else if (this.channelType === 'ALARM_SWITCH_VIRTUAL_RECEIVER') {
// ...
} else if (this.channelType === 'ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER') {
this.sound_list.forEach(item => {
$('#node-input-acoustic-container').editableList('addItem', item);
});
} else if (this.channelType === 'DIMMER_VIRTUAL_RECEIVER') {
this.dimmer_list.forEach(item => {
$('#node-input-dimmer-container').editableList('addItem', item);
Expand Down Expand Up @@ -328,6 +361,14 @@
this.dimmer_list = dimmer_list;
break;
}
case 'ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER': {
const sound_list = [];
$('#node-input-acoustic-container').editableList('items').each(function () {
sound_list.push({sound: $(this).find('select.sound').val()});
});
this.sound_list = sound_list;
break;
}
case 'KEY':
break;

Expand Down Expand Up @@ -401,7 +442,7 @@

<div class="form-row SUBMIT ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER">
<label for="node-input-acoustic"><i class="icon-envelope"></i> Sounds</label>
<ol id="node-input-dimmer-acoustic"></ol>
<ol id="node-input-acoustic-container"></ol>
</div>

<div class="form-row SUBMIT ALARM_SWITCH_VIRTUAL_RECEIVER">
Expand Down Expand Up @@ -466,8 +507,8 @@
</div>

<div class="form-row SUBMIT ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER ">
<label for="node-input-acoustic_level"><i class=""></i> Lautstärke </label>
<input id="node-input-acoustic_level" type="number" min="0" max="100">
<label for="node-input-sound_level"><i class=""></i> Lautstärke </label>
<input id="node-input-sound_level" type="number" min="0" max="100">
</div>

<div class="form-row SUBMIT DIMMER_VIRTUAL_RECEIVER ">
Expand Down
20 changes: 19 additions & 1 deletion nodes/ccu-signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function (RED) {
OPTICAL_ALARM_SELECTION: config.optical_alarm_selection
}]);
break;
case 'DIMMER_VIRTUAL_RECEIVER':
case 'DIMMER_VIRTUAL_RECEIVER': {
const params = {
LEVEL: config.dimmer_level / 100,
RAMP_TIME_UNIT: config.ramp_time_unit,
Expand All @@ -54,6 +54,24 @@ module.exports = function (RED) {
});
this.ccu.methodCall(config.iface, 'putParamset', [config.channel, 'VALUES', params]);
break;
}
case 'ACOUSTIC_SIGNAL_VIRTUAL_RECEIVER': {
const params = {
LEVEL: config.sound_level / 100,
RAMP_TIME_UNIT: config.ramp_time_unit,
RAMP_TIME_VALUE: Number(config.ramp_time_value),
DURATION_UNIT: config.duration_unit,
DURATION_VALUE: parseInt(config.duration_value, 10) || 0,
REPETITIONS: Number(config.repetitions),
OUTPUT_SELECT_SIZE: config.sound_list.length
};
config.sound_list.forEach((item, i) => {
const index = i + 1;
params['SOUNDFILE_LIST_' + index] = Number(item.sound);
});
this.ccu.methodCall(config.iface, 'putParamset', [config.channel, 'VALUES', params]);
break;
}
default:
console.error('channelType', config.channelType, 'unknown');
}
Expand Down

0 comments on commit aa9106d

Please sign in to comment.