GithubHelp home page GithubHelp logo

mozaik-ext-weather's Introduction

Mozaïk weather widgets

License Travis CI NPM version Dependencies Coverage Status widget count

Weather Client Configuration

In order to use the Mozaïk weather widgets, you must configure its client.

parameters

key env key required description
token WEATHER_API_TOKEN yes openweathermap api token

using config.js

{
  //…
  api: {
    weather: {
      apiToken: 'secret_api_token'
    }
  }
}

using environment variable

Simply set WEATHER_API_TOKEN env variable, using .env or manually.

Weather — Weather

Show weather for given city/country

clock

parameters

key required description
city yes  The city you want to display weather for.
country yes The country you want to display weather for.
lang no Lang used to display weather info. Defaults to en.
limit no Limit displayed days. Defaults to 3.

usage

{
    type:    'weather.weather',
    city:    'Paris',
    country: 'FR',
    lang:    'fr',
    limit:   2,
    columns: 1, rows: 1,
    x: 0, y: 0
},
{
    type:    'weather.weather',
    city:    'Tokyo',
    country: 'JP',
    lang:    'en',
    limit:   3,
    columns: 1, rows: 1,
    x: 1, y: 0
},
{
    type:    'weather.weather',
    city:    'Barcelona',
    country: 'ES',
    lang:    'es',
    limit:   4,
    columns: 1, rows: 1,
    x: 2, y: 0
}

mozaik-ext-weather's People

Contributors

eb-h avatar juhamust avatar plouc avatar sebastiandemel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mozaik-ext-weather's Issues

Problems with adding Weather Widget//Mozaik demo v1

item info notes
node v8.10.0 output from node --version
npm 3.5.2 output from npm --version
mozaik-ext-weather ^1.2.0 available in project's package.json
mozaik version 1.4.4 available in project's package.json
mozaik-demo version v1 version of the demo used, depends on which method you used to setup your Mozaïk dashboard
component mozaik-ext-weather name of the extension's component or client if it's related to the extension's client
browser Chrome browser used, applyable if the issue is not related to the client

Expected behavior

Display the widget, in the wanted place.

Actual behavior

the page is blank, no error, but if I remove the weather widget it works.

Steps to reproduce

-- > I installed the demo v1
--> yarn install && yarn start works
--> yarn install mozaik-ext-weather
-->Configured Config.js with
api: {
aws: {
region: 'eu-west-1'
},
weather: {
apiToken:'api...'
},
--> relaunch with yarn install && yarn start
And it is not working! I'm a rookie so it might be a stupid error, thanks for reading it, all help is appreciated!

error: weather.apiToken: must be of type String

item info notes
node version v6.9.1 output from node --version
npm version 3.10.8 output from npm --version
mozaik-ext-weather version 1.2.0 available in project's package.json
mozaik version 1.4.4 available in project's package.json
mozaik-demo version v1 version of the demo used, depends on which method you used to setup your Mozaïk dashboard
browser browser used, applyable if the issue is not related to the client

Expected behavior

node app.js
info: registered API 'mozaik' (mode: poll)
info: registered API 'github' (mode: poll)
info: registered API 'travis' (mode: poll)
info: registered API 'weather' (mode: poll)
info: serving static contents from /Users/username/mozaik-demo/build
info: Mozaïk server listening at http://0.0.0.0:5000

Actual behavior

node app.js
info: registered API 'mozaik' (mode: poll)
info: registered API 'github' (mode: poll)
info: registered API 'travis' (mode: poll)
error: weather.apiToken: must be of type String

Steps to reproduce

git clone https://github.com/plouc/mozaik-demo.git
cd mozaik-demo
npm install mozaik-ext-weather --save

Set App.jsx to

import React   from 'react';
import Mozaik  from 'mozaik/browser';
import github  from 'mozaik-ext-github';
import travis  from 'mozaik-ext-travis';
import time    from 'mozaik-ext-time';
import weather from 'mozaik-ext-weather';


const MozaikComponent = Mozaik.Component.Mozaik;
const ConfigActions   = Mozaik.Actions.Config;


Mozaik.Registry.addExtensions({
    github,
    travis,
    time,
    weather,
});

React.render(<MozaikComponent/>, document.getElementById('mozaik'));

ConfigActions.loadConfig();

config.js should have

...
// clients configs
    api: {
        aws: {
            region: 'eu-west-1'
        },
        jenkins: {
            baseUrl: 'https://my-jenkins.com',
            auth: {
                user:     'me',
                password: 'me'
            }
        },
        weather: {
            token: 'api key redacted'
        }
    },

    // define duration between each dashboard rotation (ms)
    rotationDuration: 8000,

    // define the interval used by Mozaïk Bus to call registered APIs
    apisPollInterval: 15000,

    dashboards: [

        // first dashboard
        {
            // 4 x 3 dashboard
            columns: 4,
            rows:    3,
            widgets: [
                {
                    type: 'weather.weather',
                    city:    'Paris',
                    country: 'FR',
                    lang:    'en',
                    limit:   2,
                    columns: 1, rows: 1,
                    x: 0, y: 0
                },
...

as explained here https://github.com/plouc/mozaik-ext-weather#using-configjs

Steps to fix

In config.js set api.weather.apiToken instead of api.weather.token

Can't initiate basic weather configuration

item info notes
node version v8.3.0
npm version 5.5.1
mozaik-ext-weather version ^1.2.0
mozaik version 1.4.4
mozaik-demo version don't know - github snapshot downloaded on Dec4
component don't know
browser chrome safari on mac

Expected behavior

Weather widget to appear in dashbaord.

Actual behavior

It makes server crash with the exception:

Error: Unable to find API matching id 'weather'
    at Object.clientSubscription (Bus.js:160:19)
    at WebSocket.<anonymous> (server.js:53:24)
    at emitTwo (events.js:125:13)
    at WebSocket.emit (events.js:213:7)
    at Receiver.ontext (/Users/fatih/Applications/mozaik/node_modules/ws/lib/WebSocket.js:841:10)
    at /Users/fatih/Applications/mozaik/node_modules/ws/lib/Receiver.js:536:18
    at /Users/fatih/Applications/mozaik/node_modules/ws/lib/Receiver.js:368:7
    at /Users/fatih/Applications/mozaik/node_modules/ws/lib/PerMessageDeflate.js:249:5
    at afterWrite (_stream_writable.js:438:3)
    at onwrite (_stream_writable.js:429:7)
    at InflateRaw.afterTransform (_stream_transform.js:90:3)
    at Zlib.callback (zlib.js:514:5)

I've tried the open weather api token in both config.js and environment.

Steps to reproduce

Just run the server with following weather config:

{
    type:    'weather.weather',
    city:    'New York',
    country: 'USA',
    columns: 1, rows: 1,
    x: 1, y: 0
}
```

open weather API has moved the 16 day forecast to a paid model

Expected behavior

When using the weather widget I will see a forecast

Actual behavior

I cannot see a forecast and get a 401 error from the weather API. This is due to their 16 day forecast endpoint now being paid only.

Steps to reproduce

Use the widget with a free account to see the 401 errors.

NOTE

I already have the widget working again using the day forecast. The JSON response is slightly different for that so the JSX needs to get updated. I will submit a pull request once I have it fixed and working again. Additionally, there are also new air quality codes for forecast that need to be added to WeatherCodeHelper which I have also already done.

Usage Example

It would be nice to have a usage example like there is for mozaik-ext-time that shows the configuration options and whatnot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.