WeatherModule

The WeatherModule class provides information about the current weather

Example

//==============================================================================
// The following example demonstrates how to get local weather information
//
// NOTE: Mock information is provided until the effect is published as neither
// the simulator or player app have access to location information
//==============================================================================

// Load in the required modules
const Diagnostics = require('Diagnostics');
const Weather = require('Weather');

// Send a request to get weather information
Weather.getWeather().then(function(weatherJson) {

  // Store the sunrise and sunset times
  const sunrise = weatherJson.sunriseHour + ':' + weatherJson.sunriseMinute;
  const sunset = weatherJson.sunsetHour + ':' + weatherJson.sunsetMinute;

  // Log the sunrise and sunset times
  Diagnostics.log('Sunrise => ' + sunrise);
  Diagnostics.log('Sunset => ' + sunset);

  // Detect the preffered temperature unit and log the correct value
  if(weatherJson.preferredTempUnit === 'CELSIUS') {
    Diagnostics.log('Temperature => ' + weatherJson.tempCelsius + 'C');
  } else {
    Diagnostics.log('Temperature => ' + weatherJson.tempFahrenheit + 'F');
  }

  // Log the current weather conditions
  Diagnostics.log('Weather => ' + weatherJson.currentConditionCode);

});

Properties

This module exposes no properties.

Methods

MethodDescription

getWeather

getWeather(): Promise<Weather>

Returns a JS Promise which will be fulfilled with Weather object or an error.

Classes

This module exposes no classes.