Read the statement by Michael Teeuw here.
Need some advise. Digital Ocean Modules
-
can you show what you’ve got so far and what you want to use from the api (e.g. which methods) ?
-
@strawberry-3.141 I would like to pull the IP and Name and the Status. and here is a copy of my MMM-Digital-Ocean.js file https://raw.githubusercontent.com/andyipod1437/MMM-Digital-Ocean/master/MMM-Digital-Ocean.js
-
this should give you a litte help
node_helper.jsconst DIGITALOCEAN = require('dropletapi').Droplets; const NodeHelper = require('node_helper'); module.exports = NodeHelper.create({ digitalocean: null, start: function() { console.log("Starting module: " + this.name); }, socketNotificationReceived: function(notification, payload) { if (notification === "CONFIG") { this.config = payload; this.digitalocean = new DIGITALOCEAN(this.config.api_key); setInterval(() => { this.getData(); }, this.config.updateInterval); this.getData(); } }, getData: function() { this.digitalocean.listDroplets((error, result) => { if (error) { console.log(error); } else { this.sendSocketNotification("DATA", result); } }); } });
MMM-Digital-Ocean.js in start method
this.sendSocketNotification("CONFIG", this.config);
in socketNotificationReceived
if(notification === "DATA"){ this.droplets = payload; }
in getDom you can iterate over all droplets and build the output you want
-
where do i add the very last part ?
-
@andrewchumchal also in MMM-Digital-Ocean.js
-
Any where ? or in a function called socketNotificationReceived
-
socketNotificationReceived: function(notification, payload){ if(notification === "DATA"){ this.droplets = payload; } },
-
@strawberry-3.141
Thanks again for all of you help. Now I just need to get the getDom to work :) -
Any ideas where i can start? like where i can get the name and status.
-
for(var i = 0; i < this.droplets.droplets.length; i++;){ var name = this.droplets.droplets[i].name; var status = this.droplets.droplets[i].status; var ip = ''; for(var n = 0; n < this.droplets.droplets[i].networks['v4'].length; n++;){ ip += this.droplets.droplets[i].networks['v4'].ip_address + ' | '; } for(var n = 0; n < this.droplets.droplets[i].networks['v6'].length; n++;){ ip += this.droplets.droplets[i].networks['v6'].ip_address + ' | '; } ip = ip.replace(/ | $/, ''); }