UNPKG

node-red-contrib-dwd-local-weather

Version:

Node Red node to retrieve local weather forecast from DWD (Germany)

117 lines (103 loc) 6.02 kB
<script type="text/javascript"> RED.nodes.registerType('dwdweather',{ category: 'weather', color: '#FFCC66', defaults: { name: { "value": "" }, mosmixStation: { "value": null, "required": true, "validate": RED.validators.regex(/[A-Z0-9]{3,5}/) }, lookAheadHours: { "value": "0", "required": true, "validate": RED.validators.number() }, additionalFields: { "value": "" }, omitMessageOnStart: { "value": true }, repeat: { "value": "0", "validate":function(v) { return (v>=0); } }, topic: { "value": "" }, }, inputs:1, outputs:1, icon: "feed.png", label: function() { return this.name||"dwdweather"; } }); </script> <script type="text/x-red" data-template-name="dwdweather"> <div class="form-row"> <label for="node-input-mosmixStation"><i class="icon-map-marked"></i> <span data-i18n="dwdweather.label.mosmixStation"></span></label> <input type="text" id="node-input-mosmixStation" placeholder="mosmixStation"> </div> <div class="form-row" style="padding-left: 10px"> <span data-i18n="dwdweather.description.mosmixStation"></span><a href="https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/mosmix_stationskatalog.cfg" target="_blank"><span data-i18n="dwdweather.description.mosmixStationLinkText"></span></a> </div> <div class="form-row"> <label for="node-input-lookAheadHours"><i class="icon-arrow-right"></i> <span data-i18n="dwdweather.label.lookAheadHours"></span></label> <input type="text" id="node-input-lookAheadHours" placeholder="lookAheadHours"> </div> <div class="form-row" style="padding-left: 10px"> <span data-i18n="dwdweather.description.lookAheadHours"></span> </div> <div class="form-row"> <label for="node-input-omitMessageOnStart"><i class="fa fa-crosshairs"></i> <span data-i18n="dwdweather.label.omitMessageOnStart"></span></label> <input type="checkbox" id="node-input-omitMessageOnStart" placeholder="omitMessageOnStart"> </div> <div class="form-row"> <label for="node-input-repeat"><i class="icon-repeat"></i> <span data-i18n="dwdweather.label.repeat"></span></label> <input type="text" id="node-input-repeat" placeholder="Repeat"> </div> <div class="form-row"> <label for="node-input-additionalFields"><i class="icon-bars"></i> <span data-i18n="dwdweather.label.additionalFields"></span></label> <input type="text" id="node-input-additionalFields" placeholder="additionalFields"> </div> <div class="form-row" style="padding-left: 10px"> <span data-i18n="dwdweather.description.additionalFields"></span><a href="https://www.dwd.de/DE/leistungen/opendata/help/schluessel_datenformate/kml/mosmix_elemente_xls.html" target="_blank"><span data-i18n="dwdweather.description.additionalFieldsLinkText"></span></a> </div> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="dwdweather.label.name"></span></label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-topic"><i class="icon-tasks"></i> <span data-i18n="dwdweather.label.topic"></span></label> <input type="text" id="node-input-topic" placeholder="Topic"> </div> </script> <script type="text/x-red" data-help-name="dwdweather"> <p>A node that returns German DWD MOSMIX current / forecasted weather for a given location when an input is received.</p> <h3>Input</h3> <dl class="message-properties"> <dt class="optional">payload.lookAheadHours <span class="property-type">number</span> </dt> <dd> gives weather forecast in a given number of hours. </dd> </dl> <h3>Outputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">string</span></dt> <dd>the standard output of the node.</dd> </dl> <h3>Details</h3> <p>The <b>location</b> of the forecast, an <b>internal polling</b> cycle time, <b>additional weather data</b> elements are configured via the <b>node configuration</b>.</p> <p>The node will either return <b>actual</b> weather conditions or the <b>forecast</b> in a given number of hours (via the node configuration or the input <code>msg.payload.lookAheadHours</code>). </p> <h4>Output <code>msg.payload</code> details</h4> <p><code>msg.payload</code> is used as the payload of the published message. It contains the following elements:</p> <p> <ul> <li><code>payload.station</code> - Description of the station location</li> <li><code>payload.tempc</code> - Temperature in °C</li> <li><code>payload.humidity</code> - Relative humidity</li> <li><code>payload.windspeed</code> - Windspeed in m/s</li> <li><code>payload.winddirection</code> - Winddirection in °</li> <li><code>payload.precipitation_perc</code> - probability of rain in per cent (so a value of 4 means 4%)</li> <li><code>payload.precipitationNext24h</code> - total precipitation in the next 24 hours in kg/m2</li> <li><code>payload.forecast_dt</code> - epoch timestamp of the forecast</li> <li><code>payload.precipitation%</code> - DEPRECATED, same as `payload.precipitation_perc`</li> </ul> </p> <p>Additional elements in <code>msg.payload</code> can be added via the node configuration property <em><b>Additional fields</b></em>.</p> <h3>References</h3> <ul> <li>Weather location: <a href="https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/mosmix_stationskatalog.cfg">MOSMIX station catalog</a> </li> <li>Additional elements code: <a href="https://www.dwd.de/DE/leistungen/opendata/help/schluessel_datenformate/kml/mosmix_elemente_xls.html">MOSMIX elements list</a> </li> </ul> </script>