node-red-contrib-yr
Version:
A collection of Node-RED nodes for accessing yr.no weather info and data.
76 lines (73 loc) • 2.97 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 info">
<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-forecastView"> Type</span>
<select id="node-input-forecastView" style="width:100px;">
<option value="graf" selected>Graph</option>
<option value="daglig-tabell">Table</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 info">
<h4>Yr weather info</h4>
<p>Find Yr wather forecast URL for selected location.</p>
<p>Input: msg.payload - Latitude & longitude properties</p>
<p>
Example:
{
latitude: 59.543,
longitude: 10.345
}
</p>
<p>Output: msg.payload - JSON containing Yr Web URL.</p>
<p>
Example:
{
forecast: "https://www.yr.no/nb/v%C3%A6rvarsel/daglig-tabell?lat=60&lng=10"
}
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('weather info', {
category: 'yr',
color: 'LightBlue',
defaults: {
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; } },
forecastView: { value: 'graph' },
name: { value: '' }
},
inputs: 1,
outputs: 1,
icon: 'yr.png',
label: function () {
return this.name || 'weather info';
},
paletteLabel: function () {
return this.name || 'weather info';
}
});
</script>