2
0

doc(main): update documentation and flows

This commit is contained in:
Pierre CLEMENT
2018-03-21 23:29:36 +01:00
parent c850ca9536
commit d04f5c1196
65 changed files with 2990 additions and 4 deletions

26
dist/nodes/actions/GatewayPlaySound.js vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED) => {
class GatewayPlaySound {
constructor(props) {
RED.nodes.createNode(this, props);
this.mid = parseInt(props.mid);
this.volume = parseInt(props.volume);
this.setListeners();
}
setListeners() {
this.on('input', (msg) => {
if (msg.sid) {
msg.payload = {
action: "playSound",
mid: msg.mid || this.mid,
volume: msg.volume || this.volume
};
}
this.send(msg);
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions gateway_play_sound`, GatewayPlaySound);
};

23
dist/nodes/actions/GatewayStopSound.js vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED) => {
class GatewayStopSound {
constructor(props) {
RED.nodes.createNode(this, props);
this.setListeners();
}
setListeners() {
this.on('input', (msg) => {
if (msg.sid) {
msg.payload = {
action: "playSound",
mid: 1000
};
}
this.send(msg);
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions gateway_stop_sound`, GatewayStopSound);
};

24
dist/nodes/actions/Light.js vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED) => {
class Light {
constructor(props) {
RED.nodes.createNode(this, props);
this.color = props.color;
this.brightness = props.brightness;
this.setListeners();
}
setListeners() {
this.on('input', (msg) => {
msg.payload = {
action: "setLight",
color: msg.color || this.color,
brightness: msg.brightness || this.brightness
};
this.send(msg);
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions light`, Light);
};

20
dist/nodes/actions/ReadAction.js vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED, type) => {
class ReadAction {
constructor(props) {
RED.nodes.createNode(this, props);
this.on('input', (msg) => {
if (msg.sid) {
msg.payload = {
cmd: this.type.replace(`${constants_1.Constants.NODES_PREFIX}-actions `, ''),
sid: msg.sid
};
this.send(msg);
}
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions ${type}`, ReadAction);
};

18
dist/nodes/actions/ToggleAction.js vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED, action) => {
class ToggleAction {
constructor(props) {
RED.nodes.createNode(this, props);
this.setListeners();
}
setListeners() {
this.on('input', (msg) => {
msg.payload = { action };
this.send(msg);
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions ${action}`, ToggleAction);
};

23
dist/nodes/actions/WriteAction.js vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("../constants");
exports.default = (RED, type) => {
class WriteAction {
constructor(props) {
RED.nodes.createNode(this, props);
this.on('input', (msg) => {
if (msg.sid) {
msg.payload = {
cmd: "write",
data: {
status: this.type.replace(`${constants_1.Constants.NODES_PREFIX}-actions `, ''),
sid: msg.sid
}
};
this.send(msg);
}
});
}
}
RED.nodes.registerType(`${constants_1.Constants.NODES_PREFIX}-actions ${type}`, WriteAction);
};

BIN
dist/nodes/actions/icons/mi-bulb.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

BIN
dist/nodes/actions/icons/mi-click.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
dist/nodes/actions/icons/mi-list.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

BIN
dist/nodes/actions/icons/mi-mute.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
dist/nodes/actions/icons/mi-off.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
dist/nodes/actions/icons/mi-on.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
dist/nodes/actions/icons/mi-read.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

BIN
dist/nodes/actions/icons/mi-sound.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
dist/nodes/actions/icons/mi-toggle.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

483
dist/nodes/actions/index.html vendored Normal file
View File

@@ -0,0 +1,483 @@
<script type="text/x-red" data-template-name="mi-devices-actions read">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions read">
<p>Ask the gateway to read the report of the input device.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions read',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "read",
icon: "mi-read.png",
label: function() {
return this.name||"mi-devices read";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions get_id_list">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions get_id_list">
<p>Ask the gateway to the list of devices ids.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions get_id_list',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "get id list",
icon: "mi-list.png",
label: function() {
return this.name||"mi-devices get id list";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions click">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions click">
<p>Virtual single click for switch.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions click',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "click",
icon: "mi-click.png",
label: function() {
return this.name||"mi-devices click";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions double_click">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions double_click">
<p>Virtual double click for switch.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions double_click',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "double click",
icon: "double-click.png",
label: function() {
return this.name||"mi-devices double click";
}
});
</script>
<!-- The Gateway light Node -->
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions light', {
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value: ""},
brightness: {value: 100},
hexRgbColor: {value: "#ffffff"},
color: {value:{red: 255, green: 255, blue: 255}}
},
inputs: 1,
outputs: 1,
paletteLabel: "set light",
icon: "mi-bulb.png",
label: function () {
return this.name || "set light";
},
oneditsave: function() {
var hexRgbColor = $("#node-input-hexRgbColor").val();
var split = hexRgbColor.slice(1).match(/.{1,2}/g).map(function(hexColor) {
return parseInt(hexColor, 16);
});
this.color = {
red: split[0],
green: split[1],
blue: split[2]
};
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions light">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-brightness"><i class="icon-tag"></i> Brightness</label>
<input type="range" id="node-input-brightness" min="0" max="100">
</div>
<div class="form-row">
<label for="node-input-hexRgbColor"><i class="icon-tag"></i> Color</label>
<input type="color" id="node-input-hexRgbColor">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions light">
<p>Change the light of the gateway.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>brightness
<span class="property-type">number</span>
</dt>
<dd>The brightness value between <code>0</code> and <code>100</code>.</dd>
<dt>color
<span class="property-type">object</span>
</dt>
<dd>The color itself. This object must contain the followinf properties:
<ul>
<li>
<code>red</code> - amout of red, between <code>0</code> and <code>255</code>
</li>
<li>
<code>green</code> - amout of green, between <code>0</code> and <code>255</code>
</li>
<li>
<code>blue</code> - amout of blue, between <code>0</code> and <code>255</code>
</li>
</ul>
</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Message to connect to a gateway out node.</li>
</ol>
</script>
<!-- The Gateway sound Node -->
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions gateway_play_sound', {
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value: ""},
mid: {value: ""},
volume: {value: ""}
},
inputs: 1,
outputs: 1,
paletteLabel: "play sound",
icon: "mi-sound.png",
label: function () {
return this.name || "play sound";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions gateway_play_sound">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-mid"><i class="icon-tag"></i> Sound</label>
<select id="node-input-mid">
<option value="0">Police car tone 1</option>
<option value="1">Police car tone 2</option>
<option value="2">Safety incident sound</option>
<option value="3">Missile countdown</option>
<option value="4">Ghost cry</option>
<option value="5">Sniper rifle</option>
<option value="6">Battle sound</option>
<option value="7">Air raid alarm</option>
<option value="8">Barking</option>
<option value="10">Doorbell tone</option>
<option value="11">Door knocking tone</option>
<option value="12">Funny tone</option>
<option value="13">Alarm clock tone</option>
<option value="20">MiMix</option>
<option value="21">Enthusisatic</option>
<option value="22">GuitarClassic</option>
<option value="23">IceWorldPiano</option>
<option value="24">LeisureTime</option>
<option value="25">ChildHood</option>
<option value="26">MorningStreamLet</option>
<option value="27">MusicBox</option>
<option value="28">Orange</option>
<option value="29">Thinker</option>
</select>
</div>
<div class="form-row">
<label for="node-input-volume"><i class="icon-tag"></i> Volume</label>
<input type="range" id="node-input-volume" min="0" max="100">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions gateway_play_sound">
<p>Play a sound on the gateway.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>mid
<span class="property-type">number</span>
</dt>
<dd>Music ID (user define sounds start from <code>1001</code>, <code>1000</code> means stop).</dd>
<dt>volume
<span class="property-type">number</span>
</dt>
<dd>Playing volume, between <code>0</code> and <code>100</code>.</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Message to connect to a gateway out node.</li>
</ol>
</script>
<!-- The Gateway stop sound Node -->
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions gateway_stop_sound', {
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value: ""}
},
inputs: 1,
outputs: 1,
paletteLabel: "stop sound",
icon: "mi-mute.png",
label: function () {
return this.name || "stop sound";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions gateway_stop_sound">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions gateway_stop_sound">
<p>
Stop current playing sound on the gateway.
</p>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Message to connect to a gateway out node.</li>
</ol>
</script>
<script type="text/x-red" data-template-name="mi-devices-actions turn_on">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions turn_on">
<p>Turn device on.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions turn_on',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "turn on",
icon: "mi-on.png",
label: function() {
return this.name||"mi-devices turn on";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions turn_off">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions turn_off">
<p>Turn device off.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions turn_off',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "turn off",
icon: "mi-off.png",
label: function() {
return this.name||"mi-devices turn off";
}
});
</script>
<script type="text/x-red" data-template-name="mi-devices-actions toggle">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="mi-devices-actions toggle">
<p>Toggle device.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>sid <span class="property-type">string</span></dt>
<dd>Device <code>sid</code> to ask the report.</dd>
<dt>gateway <span class="property-type">object</span></dt>
<dd>The <code>mi-devices-gateway configurator</code> object where the input device is registred.</dd>
</dl>
<h3>Outputs</h3>
<p class="node-ports">Message to connect to a gateway out node.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('mi-devices-actions toggle',{
category: 'xiaomi actions',
color: '#64C4CD',
defaults: {
name: {value:""}
},
inputs:1,
outputs:1,
paletteLabel: "toggle",
icon: "mi-toggle.png",
label: function() {
return this.name||"mi-devices toggle";
}
});
</script>

21
dist/nodes/actions/index.js vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
const ReadAction_1 = require("./ReadAction");
const WriteAction_1 = require("./WriteAction");
const Light_1 = require("./Light");
const GatewayPlaySound_1 = require("./GatewayPlaySound");
const GatewayStopSound_1 = require("./GatewayStopSound");
const ToggleAction_1 = require("./ToggleAction");
module.exports = (RED) => {
["read", "get_id_list"].forEach((action) => {
ReadAction_1.default(RED, action);
});
["click", "double_click"].forEach((action) => {
WriteAction_1.default(RED, action);
});
Light_1.default(RED);
GatewayPlaySound_1.default(RED);
GatewayStopSound_1.default(RED);
["turn_on", "turn_off", "toggle"].forEach(action => {
ToggleAction_1.default(RED, action);
});
};