Sign inSign up

2smartdev/openweathermap

By 2smartdev

•Updated almost 5 years ago

Image
0

2.2K

2smartdev/openweathermap repository overview

⁠Virtual device - Weather station(OpenWeatherMap)

This is a virtual weather station that receives information from the OpenWeatherMap API and allows you to view weather conditions for a specific city in the 2Smart Cloud mobile application.

You can install the 2Smart Cloud mobile application in the App Store⁠ or Play Market⁠.

⁠Instruction to run ready-to-use virtual device

  1. Create the config.json file and insert data below:
{
    "mqttUri":"mqtt://cloud.2smart.com:1883",
    "wssUri":"wss://cloud.2smart.com/mqtt",
    "userEmail":"",
    "productId":1635274929545301,
    "token":"",
    "deviceId":"",
    "firmwareVersion":"1"
}
  1. Insert your user email into userEmail field and device access token into token field. You could get this parameters in Account settings screen in the 2Smart Cloud mobile application.
  2. Run the following command to start the device:
docker run --name weather-station --restart always -d -v "${PWD}:/config" 2smartdev/openweathermap:cloud

The device will appear in your mobile application in a few seconds.

In the current example, the device will started with the default OpenWeatherMap AppId. If you want to change it, please read the "Additional configuration" topic.

⁠Additional configuration

A configuration file consists of the following required fields and must have the name config.json :

{
  "mqttUri": "",
  "userEmail": "",
  "productId": "",
  "token": "",
  "deviceId": "",
  "openWeatherMap": {
    "appId": ""    
  }
}

Fill each field according to the next descriptions:

  • mqttUri - a production or sandbox 2smart-cloud app URI
  • userEmail - an email related to your account
  • productId - a product's ID
  • token - a 2smart-cloud access token(sandbox or production), if you downloaded the production configuration file, then this field would be empty, read the "Retrieve production token" topic to get this token, then paste it here
  • deviceId - a device ID, leave it empty if your entered production MQTT URI, it will be generated automatically

Optional: if you want to specify OpenWeatherMap App ID manually, add the following fields to your config file

  • openWeatherMap
    • appId - OpenWeatherMap App ID, see how to get it in the "Create OpenWeatherMap AppId" topic

After filling the configuration file, run the following command in the same directory to start the device:

docker run --name weather-station --restart always -d -v "${PWD}:/config" 2smartdev/openweathermap:cloud

⁠Create OpenWeatherMap AppId

  1. Sign up to https://openweathermap.org/⁠
  2. Go to "API keys" tab(https://home.openweathermap.org/api_keys⁠) and write down the "Key" value, this value would be your "AppId"

⁠Instruction to create your own product based on virtual weather station

  1. Register a vendor acccount on 2Smart Cloud⁠ platform and create a product based on Virtual MCU. Look throught more about platform here https://2smart.com⁠

  2. Download the device connection data from your product's hub or wizard in the 2Smart Cloud vendor interface. To do this in the “Connection info” modal window choose the Configuration file and download it for the target environment("production" or "sandbox").

  3. Open the directory with this file in the terminal. If you downloaded the "production" configuration file then the "token" field would be empty, read the "Retrieve production token" topic to get this token and paste its value.
    (Important: if you downloaded both "production" and "sandbox" configuration files, then they must be located in different directories because they have the same name).

  4. Run the following command to start the device:

docker run --restart always -d -v "${PWD}:/config" 2smartdev/openweathermap:cloud

image

⁠Stopping and restarting the device

Run the following command to find the container id of the device:

docker ps

Find the record where "IMAGE" column equals "2smartdev/openweathermap:cloud" and copy the value of "CONTAINER ID" column for this record

⁠Stop the device

Run the following command with the retrieved container id to stop the device:

docker stop <container id>
⁠Restart the device

Run the following command with the retrieved container id to restart the device:

docker restart <container id>

Tag summary

Content type

Image

Digest

Size

56.1 MB

Last updated

almost 5 years ago

docker pull 2smartdev/openweathermap