Merge PR #402: New Plugin: Where the ISS at?
commit
535e8888c9
|
|
@ -1022,6 +1022,21 @@ Description: nymea.io plugin to connect to your Tado account
|
||||||
This package will install the nymea.io plugin for Tado
|
This package will install the nymea.io plugin for Tado
|
||||||
|
|
||||||
|
|
||||||
|
Package: nymea-plugin-wheretheissat
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends},
|
||||||
|
${misc:Depends},
|
||||||
|
nymea-plugins-translations,
|
||||||
|
Description: nymea.io plugin to monitor the ISS position
|
||||||
|
The nymea daemon is a plugin based IoT (Internet of Things) server. The
|
||||||
|
server works like a translator for devices, things and services and
|
||||||
|
allows them to interact.
|
||||||
|
With the powerful rule engine you are able to connect any device available
|
||||||
|
in the system and create individual scenes and behaviors for your environment.
|
||||||
|
.
|
||||||
|
This package will install the nymea.io plugin for wheretheiss.at
|
||||||
|
|
||||||
|
|
||||||
Package: nymea-plugin-zigbee-lumi
|
Package: nymea-plugin-zigbee-lumi
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${shlibs:Depends},
|
Depends: ${shlibs:Depends},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
wheretheissat/integrationpluginwheretheissat.json usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/wheretheissat/
|
||||||
|
wheretheissat/integrationpluginwheretheissat.js usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/wheretheissat/
|
||||||
|
wheretheissat/wheretheissat.mjs usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/wheretheissat/
|
||||||
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Where the ISS at?
|
||||||
|
|
||||||
|
This is a simple plugin to track the current position of the ISS.
|
||||||
|
|
||||||
|
While this plugin works and does what it is supposed to do, it is mostly meant as an example plugin to demonstrate writing nymea plugins in JavaScript.
|
||||||
|
|
||||||
|
## More
|
||||||
|
|
||||||
|
[wheretheissat.at](http://wheretheiss.at)
|
||||||
|
[API documentation](https://wheretheiss.at/w/developer)
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
import { getSatellites } from "./wheretheissat.mjs";
|
||||||
|
import { getSatelliteData } from "./wheretheissat.mjs";
|
||||||
|
|
||||||
|
var pluginTimer;
|
||||||
|
|
||||||
|
export function init() {
|
||||||
|
console.warn("JS init called!");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function discoverThings(info) {
|
||||||
|
getSatellites( (response) => {
|
||||||
|
for (var i = 0; i < response.length; i++) {
|
||||||
|
var params = [];
|
||||||
|
var param = {};
|
||||||
|
param.paramTypeId = "1d10b8e2-aea4-495c-8b1f-f44ef088f667";
|
||||||
|
param.value = response[i].id
|
||||||
|
params.push(param)
|
||||||
|
info.addThingDescriptor("4bdedd0b-e268-4671-9b3e-948c853b7b9b", response[i].name, "Satellite", params);
|
||||||
|
};
|
||||||
|
info.finish(Thing.ThingErrorNoError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setupThing(info) {
|
||||||
|
var device = info.thing;
|
||||||
|
var satelliteId = info.thing.paramValue("1d10b8e2-aea4-495c-8b1f-f44ef088f667");
|
||||||
|
if (satelliteId === undefined) {
|
||||||
|
console.warn("Could not find satelliteId in params")
|
||||||
|
info.finish(Thing.ThingErrorMissingParameter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSatelliteData(satelliteId, (response) => {
|
||||||
|
device.setStateValue("d702143f-9454-412b-88df-83b5655a5000", response.latitude)
|
||||||
|
device.setStateValue("42d9b2a1-0e51-4a92-9804-8f6f68ed6fd1", response.longitude)
|
||||||
|
info.finish(Thing.ThingErrorNoError);
|
||||||
|
|
||||||
|
pluginTimer = hardwareManager.pluginTimerManager.registerTimer(5);
|
||||||
|
pluginTimer.timeout.connect(function() {
|
||||||
|
getSatelliteData(satelliteId, (response) => {
|
||||||
|
device.setStateValue("d702143f-9454-412b-88df-83b5655a5000", response.latitude)
|
||||||
|
device.setStateValue("42d9b2a1-0e51-4a92-9804-8f6f68ed6fd1", response.longitude)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function thingRemoved(thing) {
|
||||||
|
hardwareManager.pluginTimerManager.unregisterTimer(pluginTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"name": "whereTheIssAt",
|
||||||
|
"displayName": "Where the ISS at?",
|
||||||
|
"id": "aca9d478-25c9-435f-b8d2-caf9c39a9b19",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "nymea",
|
||||||
|
"displayName": "nymea GmbH",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
|
||||||
|
"thingClasses": [
|
||||||
|
{
|
||||||
|
"name": "satellite",
|
||||||
|
"displayName": "Satellite monitor",
|
||||||
|
"id": "4bdedd0b-e268-4671-9b3e-948c853b7b9b",
|
||||||
|
"setupMethod": "JustAdd",
|
||||||
|
"createMethods": ["Discovery", "User"],
|
||||||
|
"interfaces": [ ],
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"id": "1d10b8e2-aea4-495c-8b1f-f44ef088f667",
|
||||||
|
"name": "satelliteId",
|
||||||
|
"displayName": "Satellite ID",
|
||||||
|
"type": "QString"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateTypes":[
|
||||||
|
{
|
||||||
|
"id": "d702143f-9454-412b-88df-83b5655a5000",
|
||||||
|
"name": "latitude",
|
||||||
|
"displayName": "Latitude",
|
||||||
|
"displayNameEvent": "Latitude changed",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "42d9b2a1-0e51-4a92-9804-8f6f68ed6fd1",
|
||||||
|
"name": "longitude",
|
||||||
|
"displayName": "Longitude",
|
||||||
|
"displayNameEvent": "Longitude changed",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actionTypes":[
|
||||||
|
|
||||||
|
],
|
||||||
|
"eventTypes":[
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"title": "Where the ISS at",
|
||||||
|
"tagline": "Monitors the current ISS position.",
|
||||||
|
"icon": "iss.svg",
|
||||||
|
"stability": "consumer",
|
||||||
|
"offline": true,
|
||||||
|
"technologies": [
|
||||||
|
"network"
|
||||||
|
],
|
||||||
|
"categories": [
|
||||||
|
"sensor"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
export function getSatellites(callback) {
|
||||||
|
var request = new XMLHttpRequest()
|
||||||
|
request.open("GET", "https://api.wheretheiss.at/v1/satellites");
|
||||||
|
request.onload = function() {
|
||||||
|
var response = JSON.parse(request.response);
|
||||||
|
callback(response);
|
||||||
|
}
|
||||||
|
request.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSatelliteData(satelliteId, callback) {
|
||||||
|
var request = new XMLHttpRequest()
|
||||||
|
request.open("GET", "https://api.wheretheiss.at/v1/satellites/" + satelliteId);
|
||||||
|
request.onload = function() {
|
||||||
|
var data = JSON.parse(request.response);
|
||||||
|
callback(data);
|
||||||
|
}
|
||||||
|
request.send();
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue