node-red-contrib-yr
Version:
A collection of Node-RED nodes for accessing yr.no weather info and data.
73 lines (68 loc) • 3.08 kB
HTML
<!--
Jo Torsmyr
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/html" data-template-name="weather data">
<div class="form-row">
<span for="node-input-yrconfig"> API</span>
<input type="text" id="node-input-yrconfig">
</div>
<div class="form-row"><i class="fa fa-map-marker"></i> <span>Coordinates</span>:</div>
<span for="node-input-latitude"> Latitude</span>
<input type="text" id="node-input-latitude" placeholder="Latitude" style="width:100px;">
<span for="node-input-longitude"> Longitude</span>
<input type="text" id="node-input-longitude" placeholder="Longitude" style="width:100px;">
</div>
<div class="form-row">
<div>
<span for="node-input-forecastType"> Type</span>
<select id="node-input-forecastType" style="width:100px;">
<option value="compact" selected>Compact</option>
<option value="complete">Complete</option>
</select>
</div>
</div>
<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/html" data-help-name="weather data">
<h4>Yr weather data</h4>
<p>Lookup Yr weather weather data (in XML format) for a specific place</p>
<p>Input: msg.payload - Latitude & longitude properties</p>
<p>Output: msg.payload - JSON containing Yr weather data.</p>
<h3>Config</h3>
<dt class="optional">API <span class="property-type">string</span></dt>
<dd>Configuration node for (optionally) overriding the default Yr API URL</dd>
</script>
<script type="text/javascript">
RED.nodes.registerType('weather data', {
category: 'yr',
color: 'LightBlue',
defaults: {
yrconfig: { value: '', type: "yr-config", required: false },
latitude: { value: null, validate: function (lat) { if (lat) { var n = parseFloat(lat); return n <= 90 && n >= -90 } else return true; } },
longitude: { value: null, validate: function (lng) { if (lng) { var n = parseFloat(lng); return n <= 180 && n >= -180 } else return true; } },
forecastType: { value: 'compact' },
name: { value: '' }
},
inputs: 1,
outputs: 1,
icon: 'yr.png',
label: function () {
return this.name || 'weather data';
},
paletteLabel: function () {
return this.name || 'weather data';
}
});
</script>