Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into media_device_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Chimera authored and Claudio Chimera committed Mar 11, 2021
2 parents dbeec1e + c819768 commit 3b9f370
Show file tree
Hide file tree
Showing 5 changed files with 913 additions and 6 deletions.
281 changes: 281 additions & 0 deletions devices/light.html
Original file line number Diff line number Diff line change
Expand Up @@ -1106,3 +1106,284 @@ <h3>References</h3>
}
})
</script>

<!--
RGB Temp light
-->
<script type="text/x-red" data-template-name="google-light">
<div class="form-row">
<b>Google SmartHome Settings</b>
</div>

<div class="form-row">
<label for="node-input-client"><i class="fa fa-globe"></i> SmartHome</span></label>
<input type="text" id="node-input-client">
</div>

<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="light.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]light.placeholder.name">
</div>

<div class="form-row">
<b>Node-RED Settings</b>
</div>

<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> <span data-i18n="light.label.topic"></span></label>
<input type="text" id="node-input-topic" data-i18n="[placeholder]light.placeholder.topic">
</div>

<div class="form-row" id="device_type">
<label for="node-input-device_type"><i class="fa fa-tasks"></i> <span data-i18n="light.label.device_type"></span></label>
<select id="node-input-device_type" >
<option value="onoff" data-i18n="light.label.onoff"></option>
<option value="dimmable" data-i18n="light.label.dimmable"></option>
<option value="temperature" data-i18n="light.label.temperature"></option>
<option value="hsv" data-i18n="light.label.hsv"></option>
<option value="hsv_temp" data-i18n="light.label.hsv_temp"></option>
<option value="rgb" data-i18n="light.label.rgb"></option>
<option value="rgb_temp" data-i18n="light.label.rgb_temp"></option>
</select>
</div>

<div class="form-row">
<label style="width:auto" for="node-input-passthru"><i class="fa fa-arrow-right"></i> If <code>msg</code> arrives on input, pass through to output: </label>
<input type="checkbox" checked id="node-input-passthru" style="display:inline-block; width:auto; vertical-align:top;">
</div>

<div class="form-tips">
<b>Input</b><br/>
<code>[...]/on</code> Boolean<br>
<code>[...]/online</code> Boolean<br>
<code>[...]/brightness</code> Integer, 0 - 100<br>
<code>[...]/rgb</code> Integer, 0 - 16777215<br>
<code>[...]/temperature</code> Integer, 2000 - 9000<br>
<code>[...]/hue</code> Integer, 0 - 360<br>
<code>[...]/saturation</code> Integer, 0 - 100<br>
<code>[...]/value</code> Integer, 0 - 100<br>
<br/>
<b>Outputs</b><br/>
<code>[...]/on</code> Boolean<br>
<code>[...]/online</code> Boolean<br>
<code>[...]/brightness</code> Integer, 0 - 100<br>
<code>[...]/rgb</code> Integer, 0 - 16777215<br>
<code>[...]/temperature</code> Integer, 2000 - 9000<br>
<code>[...]/hue</code> Integer, 0 - 360<br>
<code>[...]/saturation</code> Integer, 0 - 100<br>
<code>[...]/value</code> Integer, 0 - 100<br>
<br/>
</div>
</script>

<script type="text/x-red" data-help-name="google-light">
<p>A Google Smart Home Light with on/off, brightness, temperature and color (as RGB, HSV or Temperature) facilities. Outputs a message when Google Smart Home changes the state of the light.</p>

<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer | boolean | object</span>
</dt>
<dd>state to send to Google Smart Home.</dd>
</dl>

<h3>Output</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>state received from Google Smart Home.</dd>
</dl>

<h3>Details</h3>
<h4>Node Properties - Google SmartHome Settings</h4>
<p><code>SmartHome</code> Configuration node.</p>
<p><code>Name</code> Name used by Google Smart Home.</p>
<h4>Node Properties - Node-RED Settings</h4>
<p><code>Out topic</code> Topic used by this node when sending updates from Google Smart Home.</p>
<p><code>Pass Through</code> If enabled, incoming messages will be passed onto the output. Be carefull with this setting.</p>

<h4>Input Messages</h4>
<p>If <code>msg.topic</code> is <code>brightness</code> then <code>msg.payload</code> must be an integer and tells the brightness of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Brightness for the light. Range is 0 - 100.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>rgb</code> then <code>msg.payload</code> must be an integer and tells the color of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Color for the light. Range is 0 - 16777215.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>temperature</code> then <code>msg.payload</code> must be an integer and tells the color temperature of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Color temperature for the light. Range is 2000 - 6000.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>hue</code> then <code>msg.payload</code> must be an float and tells the color hue of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Color hue for the light. Range is 0 - 1.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>saturation</code> then <code>msg.payload</code> must be an float and tells the color saturation of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Color saturation for the light. Range is 0 - 1.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>value</code> then <code>msg.payload</code> must be an float and tells the color lightness of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">integer</span>
</dt>
<dd>Color lightness for the light. Range is 0 - 1.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>on</code> then <code>msg.payload</code> must be boolean and tells the state of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> sets light to on, <code>false</code> sets light to off.</dd>
</dl>

<p>If <code>msg.topic</code> is <code>online</code> then <code>msg.payload</code> must be boolean and tells the online state of the light.</p>
<dl class="message-properties">
<dt>payload
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> sets online state to on, <code>false</code> sets online state to off.</dd>
</dl>

<p>If <code>msg.topic</code> is something other than the above topics then <code>msg.payload</code> must be an object and tells both the on state as well as the online state of the light.</p>
<dl class="message-properties">
<dt>payload.brightness
<span class="property-type">integer</span>
</dt>
<dd>Brightness for the light. Range is 0 - 100.</dd>
<dt>payload.rgb
<span class="property-type">float</span>
</dt>
<dd>RGB Color for the light. Range is 0 - 16777215.</dd>
<dt>payload.temperature
<span class="property-type">integer</span>
</dt>
<dd>Color temperature for the light. Range is 2000 - 6000.</dd>
<dt>payload.hue
<span class="property-type">float</span>
</dt>
<dd>Hue for the light. Range is 0 - 1.</dd>
<dt>payload.saturation
<span class="property-type">float</span>
</dt>
<dd>Saturation for the light. Range is 0 - 1.</dd>
<dt>payload.value
<span class="property-type">float</span>
</dt>
<dd>Value or lightness for the light. Range is 0 - 1.</dd>
<dt>payload.on
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> sets light to on, <code>false</code> sets light to off.</dd>
<dt>payload.online
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> sets online state to on, <code>false</code> sets online state to off.</dd>
</dl>

<p><b>Note 1:</b> <code>msg.topic</code> does not have to be exactly as shown above. You can use <code>/</code> as
a delimiter and as long as the last part of the topic matches one of the described topics all is good.
For example, <code>a/msg/topic/on</code> will be broken down into multiple parts and only the last part,
<code>on</code>, will be tested for a match.</p>
<p><b>Note 2:</b> If you set the online state to <code>false</code> then Google Smart Home is not going to be
able to control the light.</p>

<h4>Output Messages</h4>
<p>Unless <code>Pass Through</code> is enabled, these messages are emitted when Google Smart Home wants to control the light.</p>
<dl class="message-properties">
<dt>payload.brightness
<span class="property-type">integer</span>
</dt>
<dd>Brightness for the light. Range is 0 - 100.</dd>
<dt>payload.rgb
<span class="property-type">float</span>
</dt>
<dd>RGB Color for the light. Range is 0 - 16777215.</dd>
<dt>payload.temperature
<span class="property-type">integer</span>
</dt>
<dd>Color temperature for the light. Range is 2000 - 6000.</dd>
<dt>payload.hue
<span class="property-type">float</span>
</dt>
<dd>Hue for the light. Range is 0 - 1.</dd>
<dt>payload.saturation
<span class="property-type">float</span>
</dt>
<dd>Saturation for the light. Range is 0 - 1.</dd>
<dt>payload.value
<span class="property-type">float</span>
</dt>
<dd>Value or lightness for the light. Range is 0 - 1.</dd>
<dt>payload.on
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> light on, <code>false</code> light off.</dd>
<dt>payload.online
<span class="property-type">boolean</span>
</dt>
<dd><code>true</code> online state on, <code>false</code> online state off.</dd>
</dl>

<h3>References</h3>
<p><a href="https://developers.google.com/assistant/smarthome/guides/light" target="_new">Smart Home Light Guide</a>.</p>
<p><a href="https://www.npmjs.com/package/node-red-contrib-google-smarthome" target="_new">Node Information</a>.</p>
</script>

<script type="text/javascript">
RED.nodes.registerType('google-light', {
category: 'Google_SmartHome-function',
paletteLabel: 'Light',
defaults: {
client: {
type: "googlesmarthome-client",
required: true
},
name: {
value: "", required:true
},
topic: {
value: "", required:true
},
passthru: {
value: false
},
device_type: {
value: "onoff", required: true
},
},
inputs: 1,
outputs: 1,
color:"#C0DEED",
icon: "google-smarthome.png",
label: function() {
return this.name || this._('light.label.' + this.device_type.toLowerCase()) || "Light";
},
labelStyle: function() {
return this.name ? "node_label_italic" : ""
}
})
</script>
Loading

0 comments on commit 3b9f370

Please sign in to comment.