M2X Data Forecaster
This flow inserts weather data to M2X.
What does this flow do?
This flow retrieves weather data in XML format every 30 minutes from the National Oceanic and Atmospheric Administration (NOAA) web site. The data is parsed to a JavaScript object and is inserted into the RabbitMQ queue. The data is then retrieved from the RabbitMQ queue, and inserted to the M2X using a ‘postMultiple’ command. If the data is inserted successfully, ACK is sent to RabbitMQ queue.
Principal nodes
- inject
- http request
- XML
- rabbitMQ out
- rabbitMQ in
- function
- M2X
- json
- switch
What do I have to do before using this flow?
In order to use the M2X node, you must first log in to the M2X environment and verify the API Key and the Device ID.
In addition, you must define a data source blueprint with the following two streams:
- Temperature
- Humidity
How does this thing work?
- inject node - Triggers the http request every 30 minutes.
- http request node - Sends a GET request to retrieve weather data from NOAA.
- xml node - Parses the received XML to a JavaScript object.
- rabbitmq out node - Inserts the data into the RabbitMQ queue.
- rabbitmq in node - Receives the data from the RabbitMQ queue.
- function node - Extracts the temperature and humidity and prepares a ‘postMultiple’ command to insert the data into M2X.
- m2x node - Connects to M2X and inserts the data.
- json node - Parses the answer that was returned from M2X to object.
- switch node - If ‘success’ is returned, sends ACK to the RabbitMQ queue. In case of failure it sends an error message to the debug node.
- function node - Prepares the ‘acknowledge’ command which is sent to the RabbitMQ queue when inserting the data is successful.
Some useful things to know
This flow uses the following links:
M2X:
https://m2x.att.com/developer/documentation/overview
RabbitMQ:
http://www.rabbitmq.com/documentation.html
NOAA:
http://w1.weather.gov/xml/current_obs/KNYC.xml
Hosted RabbitMQ credentials:
User name: guest
Password: guest