node-red-contrib-twc-weather
Version:
Node-RED nodes for The Weather Company and Weather Underground Data APIs
119 lines (113 loc) • 5.18 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("pwsapikey", {
category: "config",
defaults: {
name: {value:"", required: false}
},
credentials: {
apikey: {type: "password"}
},
label: function() {
return this.name;
}
});
</script>
<script type="text/x-red" data-template-name="pwsapikey">
<div class="form-tips">
<b>Note:</b> Enter the API Key assigned from either:<br />
<ul>
<li>A purchased <a href="https://business.weather.com/products/weather-data-packages" target="_new">TWC Weather data package</a><br /></li>
<li>A registered <a href="https://callforcode.weather.com" target="_new">Promotional key for Call for Code participants</a><br /></li>
<li>A registered <a href="https://www.wunderground.com/" target="_new">Weather Underground</a> personal weather station device
</ul>
</div>
<div class="form-row">
<label for="node-config-input-apikey"><i class="fa fa-key"></i> API Key</label>
<input type="password" id="node-config-input-apikey">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Config Name</label>
<input type="text" id="node-config-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="pwsapikey">
<p>Enter the API Key assigned from either TWC or Weather Underground<br />
<ul>
<li>A purchased <a href="https://business.weather.com/products/weather-data-packages" target="_new">TWC Weather data package</a><br />
<li>A registered <a href="https://www.wunderground.com/" target="_new">Weather Underground</a> personal weather station device
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('pws-observations',{
category: 'Weather',
color: "#a2a9b0",
icon: "icons/wi-wu-partlycloudy.png",
inputs:1,
outputs:1,
defaults: {
name: { value:""},
stationid: { value:""},
units: { value:"e"},
precision: { value:"i"},
apikey: {value:"", type:"pwsapikey",required: true}
},
label: function() {
return this.name||"PWS Observations";
}
});
</script>
<script type="text/x-red" data-template-name="pws-observations">
<div class="form-row">
<label for="node-input-apikey"><i class="fa fa-key"></i> API Key</label>
<input type="text" id="node-input-apikey">
</div>
<div class="form-row">
<label for="node-input-stationid"><i class="fa fa-tag"></i> StationID</label>
<input type="text" id="node-input-stationid">
</div>
<div class="form-row">
<label for="node-input-units"><i class="fa fa-thermometer-half"></i> Unit of Measure</label>
<select id="node-input-units">
<option value="e">English units</option>
<option value="m">Metric units</option>
<option value="h">Hybrid units (UK)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-precision"><i class="fa fa-thermometer-half"></i> Numeric Precision</label>
<select id="node-input-precision">
<option value="i">Integer</option>
<option value="d">Decimal</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="pws-observations">
<p>Personal Weather Station (PWS) Current Conditions returns the current conditions observations.</p>
<p>Current record is the last record reported within 60 minutes.
If the station has not reported a current conditions in the past 60 minutes,
the response will not return an expired observation record (older than 60 minutes);
a 'Data Expired' message will be returned instead.</p>
<p>See the <a target="_blank" href="https://docs.google.com/document/d/1eKCnKXI9xnoMGRRzOL1xPCBihNV2rOet08qpE_gArAY">online documentation</a>
for more information about the <strong>The Weather Company APIs for Personal Weather Stations</strong>.</p>
<h3>Inputs:</h3>
<dl class="message-properties">
<dt class="optional">msg.twcparams.StationID <span class="property-type">string</span></dt>
<dd>If specified, override edit panel. Station ID as registered by wunderground.com</dd>
<dt class="optional">msg.twcparams.units <span class="property-type">string</span></dt>
<dd>If specified, override edit panel. 'e' - English units, 'm' - Metric units, 'h' - Hybrid units</dd>
<dt class="optional">msg.twcparams.precision <span class="property-type">string</span></dt>
<dd>If specified, override edit panel. 'i' - Integer values, 'd' - Decimal values</dd>
</dl>
<h3>Outputs:</h3>
<dl class="message-properties">
<dt class="optional">msg.payload.observations <span class="property-type">object</span></dt>
<dd>Array of json objects containing weather data elements</dd>
<dd>Find details on the <a target="_blank" href="https://ibm.co/v2PWSCC">PWS Observations Current Conditions</a> data elements and definitions.</dd>
<dt class="optional">msg.twcparams <span class="property-type">object</span></dt>
<dd>Array of json objects containing request parameters</dd>
</dl>
</script>