-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdaswetter.js
36 lines (30 loc) · 854 Bytes
/
daswetter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Cache from 'src/controllers/Cache'
import Connection from 'src/controllers/Connection'
export default 'Das Wetter'
export const namespace = 'daswetter'
/**
*
*
*/
export function root(objects, options) {
const socket = Connection.getConnection;
return new Promise((resolve, reject) => {
socket.getObject('system.adapter.daswetter.0').then(obj => {
const url = obj && obj.native && (obj.native.Days5Forecast || obj.native.Days7Forecast || obj.native.HourlyForecast || obj.native.HourlyForecastJSON);
if (url) {
const params = url.substr(url.indexOf('?') + 1).split('&');
const c = {}
params.forEach(param => {
const [ attr, value ] = param.split('=');
c[attr] = value;
});
Cache.set('daswetter', c);
}
})
.catch(() => {})
.finally(() => {
// reject
reject();
});
});
}