node-red-contrib-musiccast
Version:
A Node-RED collection for monitoring and controlling a Yamaha Musiccast network.
585 lines (533 loc) • 27 kB
HTML
<!--
Apache-2.0
Copyright (c) 2023 Vahdettin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
-->
<script type="module" src="resources/node-red-contrib-musiccast/musiccast-ui.js"></script>
<script type="text/javascript">
(function () {
const BASE = 'zone';
RED.nodes.registerType('musiccast-zone', {
category: 'Musiccast',
defaults: {
mc: {type: "musiccast-config", required: true},
name: {value: "", required: false},
device: {value: "", required: false},
type_device: {value: "", required: false},
zone: {value: "", required: false},
type_zone: {value: "", required: false},
command: {value: "getStatus", required: false},
type_command: {value: "", required: false},
payload: {value: "{}", required: false},
type_payload: {value: "json", required: false},
f_show_status: {value: false, required: false}
},
inputs: 1,
outputs: 1,
color: "#9c86bc",
label: function () {
return this.name || this.command;
},
icon: "font-awesome/fa-map-marker",
align: 'right',
paletteLabel: "zone",
oneditprepare: function () {
let mc = RED.nodes.node($("#node-input-mc").val()) || null;
let ui = new MCUI(BASE, mc, RED);
const Fields = ui.cFields;
let mcZoneDraw = function (done) {
ui.popZones(null, function (err, curZone) {
if (curZone) {
ui.popDevices(curZone, function (err, curDev) {
ui.popCommands(curDev, function (err, curCommand) {
ui.loadCommand(curCommand, function (err, curCommand) {
})
ui.popAttributes();
done(true);
});
});
}
});
}
mcZoneDraw(function (drawn) {
if (drawn) {
Fields.c.on('change', function (event, type, value) {
ui.loadCommand({
v: value,
t: Fields.c.typedInput("type")
},function(err,curCommand){})
});
Fields.d.on('change', function (event, type, value) {
ui.popCommands({
v: value,
t: Fields.d.typedInput("type")
}, function (err, curCommand) {
});
});
Fields.z.on('change', function (event, type, value) {
ui.popDevices({
v: value,
t: Fields.z.typedInput("type")
}, function (err, curDev) {
});
});
Fields.p.on('change', function (event, type, value) {
if (type && type === 'json') {
if (!value) {
Fields.p.typedInput('value', '{}')
}
}
});
$("#lookup-command").on("click", function () {
ui.showSidebarHelpPanel({
v: Fields.c.typedInput("value"),
t: Fields.c.typedInput("type")
});
});
$("#set-attribute-default").on("click", function () {
ui.popExampleAttributes({
v: Fields.c.typedInput("value"),
t: Fields.c.typedInput("type")
}, function (err, data) {
})
});
RED.events.on("nodes:change", function (theNode) {
if (theNode && theNode.type === 'musiccast-config') {
if (theNode.dirty && theNode.dirty !== false && theNode.valid && theNode.valid !== false) {
ui.refresh(theNode,function(err,done){
ui.popZones(null, function (err, curZone) {
})
})
}
}
});
ui.finish();
}
});
},
oneditsave: function () {
let mc = RED.nodes.node($("#node-input-mc").val()) || null;
let ui = new MCUI(BASE, mc);
const Fields = ui.cFields;
$("#lookup-command").off();
$("#set-attribute-default").off();
this.zone = Fields.z.typedInput("value");
this.device = Fields.d.typedInput("value");
this.command = Fields.c.typedInput("value");
this.payload = Fields.p.typedInput("value");
},
oneditcancel: function () {
$("#lookup-command").off();
$("#set-attribute-default").off();
}
});
})();
</script>
<script type="text/html" data-template-name="musiccast-zone">
<link rel="stylesheet" href="resources/node-red-contrib-musiccast/style.css"/>
<div>
<span id="notification_message"></span>
</div>
<div class="form-row">
<label for="node-input-mc"> Musiccast</label>
<input type="text" id="node-input-mc">
</div>
<div class="form-row">
<label for="node-input-zone"><i class="fa fa-map-marker"></i> Zone</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<div style="position: absolute; left: 0px; right: 40px;">
<input type="text" id="node-input-zone" style="width:80%">
</div>
</div>
</div>
<div class="form-row ">
<label for="node-input-device"><i class="fa fa-crosshairs"></i> Device</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<div style="position: absolute; left: 0px; right: 40px;">
<input type="text" id="node-input-device" style="width:80%">
</div>
</div>
</div>
<div class="form-row ">
<label for="node-input-command"><i class="fa fa-cogs"></i> Command</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<div style="position: absolute; left: 0px; right: 40px;">
<input type="text" id="node-input-command" style="width:100%">
</div>
<a id="lookup-command" class="red-ui-button" style="position: absolute; right: 0px; top: 0px;"><i
class="fa fa-book"></i></a>
</div>
</div>
<div class="form-row musiccast-form-row-cmd-addt">
<label> </label>
<input type="checkbox" id="node-input-f_show_status"
style="display:inline-block; width:15px; vertical-align:baseline;" autocomplete="off">
<label style="width: 60% !important;" for="node-input-f_show_status"
title="Show power status for the designated zone on the palette when command runs.">Show on
palette</label>
</div>
<div class="form-row musiccast-form-row-payload">
<label for="node-input-payload"><i class="fa fa-puzzle-piece"></i> Attributes</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<div style="position: absolute; left: 0px; right: 40px;">
<input type="text" id="node-input-payload" style="width:100%">
</div>
<a id="set-attribute-default" class="red-ui-button"
style="position: absolute; right: 0px; top: 0px;"><i class="fa fa-paste"></i></a>
</div>
</div>
<div class="form-row ">
<label for="node-input-name"><i class="fa fa-tag"></i> Label</label>
<div style="display: inline-block; position: relative; width: 70%; height: 20px;">
<div style="position: absolute; left: 0px; right: 40px;">
<input type="text" id="node-input-name" placeholder="optional" style="width:100%">
</div>
</div>
</div>
<div class="form-row musiccast-form-row-ah">
<input type="text" id="node-input-type_zone">
</div>
<div class="form-row musiccast-form-row-ah">
<input type="text" id="node-input-type_command">
</div>
<div class="form-row musiccast-form-row-ah">
<input type="text" id="node-input-type_payload">
</div>
<div class="form-row musiccast-form-row-ah">
<input type="text" id="node-input-type_device">
</div>
</script>
<script type="text/html" data-help-name="musiccast-zone">
<link rel="stylesheet" href="resources/node-red-contrib-musiccast/style.css"/>
<p>
Execute Zone functions such as power toggling and setting of volume.</p>
<h4>Yamaha API Relationship</h4>
<p>The Yamaha API command types included in this node are:</p>
<dl>
<dd>
<ul>
<li>Zone </li>
</ul>
</dd>
</dl>
<h4>Basic Configuration</h4>
<p>The following items can only be set via the palette editor. All other configuration items can be set in the
editor or via inbound message or context variable. Details for these items are in the Input section below. </p>
<dl>
<dt>Musiccast</dt>
<dd>Select the Musiccast configuration to use.</dd>
<dt>Label</dt>
<dd>Optional. Enter a name for the node or the default will be assigned.</dd>
<dt>Show on palette</dt>
<dd>Optional. If this option appears under the Command dropdown and is checked, basic information from a
response will be displayed on the palette under the node when a command is sent.
</dl>
<h4>Helpful Features</h4>
<p>There are several buttons that when clicked, provide helpful functionality to assist with configuration.</p>
<dl>
<dd>
<ul>
<li><a class="red-ui-button"><i class="fa fa-question"></i></a> Shows inline help for the selected
command.
</li>
<li><a class="red-ui-button"><i class="fa fa-paste"></i></a> Populates the Attributes field with example
values to start with.
</li>
</ul>
</dd>
</dl>
<h3>Input</h3>
<dl class="message-properties">
<dt>zone
<span class="property-type">string</span>
</dt>
<dd> The zone system name or label.
</dd>
<dt>device
<span class="property-type">string</span>
</dt>
<dd> The target device name or label.
</dd>
<dt>command
<span class="property-type">string</span>
</dt>
<dd> The command to send.
</dd>
<dt>attributes
<span class="property-type">object</span>
</dt>
<dd> Additional attributes if needed by the command. This can also be sent as <code>payload</code>.
</dd>
</dl>
<h3>Output</h3>
<dl class="message-properties">
<dt>input
<span class="property-type">string</span>
</dt>
<dd> The input label.
</dd>
<dt>device
<span class="property-type">string</span>
</dt>
<dd> The device the command was sent to.
</dd>
<dt>command <span class="property-type">string</span></dt>
<dd> The command that was sent.</dd>
<dt>payload <span class="property-type">object</span></dt>
<dd> The response received from the device. This will always include <i>response_code</i> and <i>response_message</i>.
</dd>
</dl>
<h3>Command Reference</h3>
<!-- BEGIN COMMAND HELP -->
<dl class="message-properties">
<dt id="musiccast-command-info-getconfig">getConfig</dt>
<dd>Get zone config. This is not a Musiccast function.</dd><p></p>
<dt id="musiccast-command-info-getbasicstatus">getBasicStatus</dt>
<dd>Get basic zone status. This is not a Musiccast function.</dd><p></p>
<dt id="musiccast-command-info-sceneload">sceneLoad</dt>
<dd>Load a scene by its number. This is not a Musiccast function.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"Scene":</span> <span class="string">"1|2|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setpower">setPower</dt>
<dd>Change the power state of a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"power":</span> <span class="string">"on|off|toggle|standby"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setlinkaudioquality">setLinkAudioQuality</dt>
<dd>For setting Link Audio Quality in a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"mode":</span> <span class="string">"compressed"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setlinkcontrol">setLinkControl</dt>
<dd>For setting Link Control in a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"control":</span> <span class="string">"normal"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setlinkaudiodelay">setLinkAudioDelay</dt>
<dd>For setting Link Audio Delay in a zone. This setting is invalid when Link Control setting is " Stability Boost ".</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"delay":</span> <span class="string">"lip_sync"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setautopowerstandby">setAutoPowerStandby</dt>
<dd>Change the auto power standby setting for a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setvolume">setVolume</dt>
<dd>Change the volume of a zone in steps or to a specific value.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"volume":</span> <span class="string">"up|down|1|2|..."</span>,
<span class="key">"step":</span> <span class="string">"1|...|5"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setmute">setMute</dt>
<dd>Set or unset zone mute.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-getstatus">getStatus</dt>
<dd>Get current status information about a zone. Optionally, the current power and active input can be displayed on the palette.</dd><p></p>
<dt id="musiccast-command-info-getsignalinfo">getSignalInfo</dt>
<dd>Get details on the format of the currently playing media. Optionally, the audio format and rate of media can be displayed on the palette.</dd><p></p>
<dt id="musiccast-command-info-getsoundprogramlist">getSoundProgramList</dt>
<dd>Get a list of sound programs available to device in its assigned zone.</dd><p></p>
<dt id="musiccast-command-info-setsoundprogram">setSoundProgram</dt>
<dd>Set a sound program for a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"program":</span> <span class="string">"munich|vienna|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setinput">setInput</dt>
<dd>Change to the designated playback source for a zone. Autoplay can be enabled or disabled.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"input":</span> <span class="string">"juke|tidal|qobuz|deezer|server|bluetooth|airplay|mc_link|usb"</span>,
<span class="key">"mode":</span> <span class="string">"autoplay_disabled"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setsleep">setSleep</dt>
<dd>Set the sleep timer in minutes. Set [sleep] attributes parameter to '0' to cancel an existing timer.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"sleep":</span> <span class="string">"0|...|180"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-prepareinputchange">prepareInputChange</dt>
<dd>Let a device do necessary process before changing input in a specific zone. This is valid only when 'prepare_input_change' exists in “func_list” found in /system/getFuncStatus.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"input":</span> <span class="string">"juke|tidal|qobuz|deezer|server|bluetooth|airplay|mc_link|usb"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-recallscene">recallScene</dt>
<dd>Load a pre-defined scene.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"num":</span> <span class="string">"1|2|3..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setactualvolume">setActualVolume</dt>
<dd>Calculated from minimum value, maximum value, step value of volume gotten via /system/getFeatures. Attribute [mode] also comes from /system/getFeatures</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"mode":</span> <span class="string">"up|down|1|2|..."</span>,
<span class="key">"value":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setcontentsdisplay">setContentsDisplay</dt>
<dd>Load a pre-defined scene.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setaudioselect">setAudioSelect</dt>
<dd>Audio_decoder_list gotten via /system/getFeatures.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"type":</span> <span class="string">"auto|hdmi|coax_opt|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-controlcursor">controlCursor</dt>
<dd>Simulate operation of the cursor keys on the remote control.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"cursor":</span> <span class="string">"up|down|left|right|select|return"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-controlmenu">controlMenu</dt>
<dd>Simulate operation of the menu keys on the remote control.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"menu":</span> <span class="string">"on_screen|top_menu|menu|option|display|red|green|yellow|blue"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setsurrounddecodertype">setSurroundDecoderType</dt>
<dd>List of types available via System - getFeatures</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"type":</span> <span class="string">"auto|toggle|dolby_surround|dts_neural_x|dts_neo6_cinema|dts_neo6_music"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-set3dsurround">set3dSurround</dt>
<dd>Enable or disable 3D Surround.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setdirect">setDirect</dt>
<dd>Enable or disable direct.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setpuredirect">setPureDirect</dt>
<dd>Enable or disable Pure Direct.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setenhancer">setEnhancer</dt>
<dd>Enable or disable the enhancer.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-settonecontrol">setToneControl</dt>
<dd>Set specific values for tone or set to auto.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"mode":</span> <span class="string">"manual"</span>,
<span class="key">"bass":</span> <span class="string">"1|2|3|..."</span>,
<span class="key">"treble":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setequalizer">setEqualizer</dt>
<dd>Set specific values for the equalizer or set to auto.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"mode":</span> <span class="string">"manual"</span>,
<span class="key">"low":</span> <span class="string">"1|2|3|..."</span>,
<span class="key">"mid":</span> <span class="string">"1|2|3|..."</span>,
<span class="key">"high":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setbalance">setBalance</dt>
<dd>Set the balance between right and left speakers. Negative values are for left side, positive values are for right side balance.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"value":</span> <span class="string">"-1|01|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setdialoguelevel">setDialogueLevel</dt>
<dd>Set the Dialog volume.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"value":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setclearvoice">setClearVoice</dt>
<dd>Set clear voice for a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setdialoguelift">setDialogueLift</dt>
<dd>Set the Dialog Lift volume.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"value":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setsubwoofervolume">setSubwooferVolume</dt>
<dd>Set the subwoofer volume for a zone.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"volume":</span> <span class="string">"1|2|3|..."</span>
}</pre><p></p>
</dd>
<dt id="musiccast-command-info-setbassextension">setBassExtension</dt>
<dd>Enable or disable the bass extension.</dd><p></p>
<dd>Attribute structure:
<pre class="musiccast-attributes-example">{
<span class="key">"enable":</span> <span class="string">"true|false"</span>
}</pre><p></p>
</dd>
</dl>
<!-- END COMMAND HELP -->
<h4>Collection Information</h4>
<ul>
<li>Version: 4.5.2</li>
</ul>
<div style="height: 700px;"></div>
<span>This space intentionally left blank</span>
</script>