A node red node that returns German DWD MOSMIX current / forecasted weather for a given location.
It gives you the following data:
Fig. 1: Node appearance
Remark: This node is mainly useful if you are interested in weather data for Germany. International weather data is available for only a couple of european locations (see MOSMIX stations below). Examples for international locations are Bergen, London, Dublin, Brussels, Luzern, Lille, Locarno, Le Mans, Madrid, Ibiza, Klagenfurt (and many others).
The weather data is provided by DWD (Deutscher Wetterdienst, Frankfurter Straße 135, 63067 Offenbach).
References:
~/.node-red
npm install node-red-contrib-dwd-local-weather
The easiest usage of the node is using internal triggering:
Fig. 2: Basic node usage
In this example the node cyclically reads out the DWD data and emits it as an output msg
.
Fig. 3: Node properties
Node configuration is quite simple. Only setting the property MOSMIX Station to select the required weather forecast location is mandatory.
Set this property to select the weather forecast location.
The format is a 5 character id. Allowed ids are given in the stations catalog (in CFG file format) of the DWD (german weather service): See coloumn 'id' and search for your location.
Examples:
Hours to look ahead into the future. Use 0 to get actual weather.
When you set Look ahead hours, the weather data returned will be for x hours in the future. If you look at the temperature for 12 hours ahead for example, you should see a different number returned unless that temperature happens to be exactly the same to the actual temperature.
Note: This configuration property is superseeded by an input msg
with a msg.payload.lookAheadHours
element (see secion Input below).
For compatibility with the openweathermap node, this node emits a message with current weather data immediately once the flow is deployed. If this is not desirable, it can be deactivated here. In any case, the node will emit a message after the repeat cycle in case this is set (see below) or once it is triggered by receiving a message.
Automatic cyclic repeat (in seconds). If set to a value > 0, the node automatically repeats the DWD data query and emits a msg
telegram at its output.
Hint: Do not set this value too small to avoid unneccesary traffic. Appropriate repeat intervals are several minutes due to the weather data does not change at a higher rate than 15-20 seconds, typically one minute.
With the Additional fields property you can add further weather data to msg.payload
.
Possible elements can be selected from this MOSMIX element list from the DWD.
Several elements can be selected and have to be comma-separated.
The data provided by DWD is on an hourly basis. By default, output values will be linearly interpolated. Some data fields such as "SunD" (Yesterdays total sunshine duration) in the below example are only provided once every X hours or even once per day and interpolation does not make sense. With modifiers you can change how the output value is calculated in those cases. When not specifying a modifier, the value for those fields will be 'NaN' in most cases.
Output modifiers are added as a prefix to the field name. So instead of just using "SunD", you would use ">SunD" to return today's predicted total sunshine duration.
Available modifiers:
<
go back in time to find the last value for this field>
go ahead in time to find the next value for this field°
assume the field value is a temperature and convert it from Kelvin to CelsiusSee also: Node issue "NaN error with precipitation 24h and 3h".
The following figure shows the msg.payload
structure of an example with "FF,FX1,>SunD,SunD1,R101,°Td,VV,W1W2,wwTd":
Fig. 4: Additional fields example msg.payload
contents
The following MOSMIX elements are used as the basis for the node's msg.payload
values:
payload.tempc
: "TTT"payload.humidity
: "Td" and "TTT"payload.windspeed
: "FF"payload.winddirection
: "DD"payload.precipitation_perc
: "wwP"payload.precipitationNext24h
: "RR1c"A name for the wheather location may be set via this property.
Allows to configure the topic for emitted messages.
The node is triggered by any input msg
with arbitrary contents.
If the input msg
contains the element msg.payload.lookAheadHours
its value superseeds the Look ahead Hours node configuration property.
The node emits a msg
whenever it is triggered by an input msg
or at the configured Repeat interval (see node configuration above).
The default msg
attributes are:
payload.station
- Description (location) of the stationpayload.tempc
- Temperature in °Cpayload.humidity
- Relative humiditypayload.windspeed
- Windspeed in m/spayload.winddirection
- Winddirection in °payload.precipitation_perc
- probability of rain in per cent (so a value of 4 means 4%)payload.precipitationNext24h
- total precipitation in the next 24 hours in kg/m2payload.forecast_dt
- epoch timestamp of the forecastpayload.precipitation%
- DEPRECATED, same as payload.precipitation_perc
In case of a value set to the node configuration property Topic the output msg
contains an additional attribute msg.topic
with the set content in addition to the msg.payload
object.
As an example, if the node configuration property Topic is set to "myTopic" the output msg
looks like this:
Fig. 5: Example output msg
with topic configuration property set to "myTopic"
Remark: Example flows are present in the examples subdirectory. In Node-RED they can be imported via the import function and then selecting Examples in the vertical tab menue.
This example shows how to trigger the node and how to evaluate the msg.payload.tempc
element.
Fig. 6: Basic example flow
The configuration of the property Additional fields was set to "FX1,SunD1,VV". Therefore the elements msg.payload.FX1
(max. wind gust in the lasts hour), msg.payload.SunD1
(sunshine duration in the last hour) and msg.payload.VV
(visibility) appear additionally at the output.
AdditionalFieldsExampleFlow.json
Fig. 7: Example with Additional fields flow
Note that often the values have to be scaled to have more 'handy' values.
Apache 2.0 (c) Christian Stein