Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.15.0 is available! For more information about this release, check out this topic.

    Need some advise. Digital Ocean Modules

    Development
    2
    19
    6082
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • andrewchumchal
      andrewchumchal last edited by andrewchumchal

      Hello Guys.
      I am currently writing a module for Digital Ocean with MM2. I have all it done expect for the api called. I have seen some other ones but most of them uses a url for the called. DO using a curl not a url. Any help would be thankful.

      Thanks

      PS here is the documentation for it https://www.npmjs.com/package/dropletapi

      1 Reply Last reply Reply Quote 0
      • strawberry 3.141
        strawberry 3.141 Project Sponsor Module Developer last edited by

        can you show what you’ve got so far and what you want to use from the api (e.g. which methods) ?

        andrewchumchal 1 Reply Last reply Reply Quote 0
        • andrewchumchal
          andrewchumchal @strawberry 3.141 last edited by

          @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

          1 Reply Last reply Reply Quote 0
          • strawberry 3.141
            strawberry 3.141 Project Sponsor Module Developer last edited by

            this should give you a litte help
            node_helper.js

            const 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

            andrewchumchal 1 Reply Last reply Reply Quote 0
            • andrewchumchal
              andrewchumchal @strawberry 3.141 last edited by

              @strawberry-3.141

              where do i add the very last part ?

              strawberry 3.141 1 Reply Last reply Reply Quote 0
              • strawberry 3.141
                strawberry 3.141 Project Sponsor Module Developer @andrewchumchal last edited by

                @andrewchumchal also in MMM-Digital-Ocean.js

                andrewchumchal 1 Reply Last reply Reply Quote 0
                • andrewchumchal
                  andrewchumchal @strawberry 3.141 last edited by

                  @strawberry-3.141

                  Any where ? or in a function called socketNotificationReceived

                  strawberry 3.141 1 Reply Last reply Reply Quote 0
                  • strawberry 3.141
                    strawberry 3.141 Project Sponsor Module Developer @andrewchumchal last edited by

                    @andrewchumchal

                    socketNotificationReceived: function(notification, payload){
                        if(notification === "DATA"){
                           this.droplets = payload;
                        }
                    },
                    
                    andrewchumchal 2 Replies Last reply Reply Quote 0
                    • andrewchumchal
                      andrewchumchal @strawberry 3.141 last edited by

                      @strawberry-3.141
                      Thanks again for all of you help. Now I just need to get the getDom to work 🙂

                      1 Reply Last reply Reply Quote 0
                      • andrewchumchal
                        andrewchumchal @strawberry 3.141 last edited by

                        @strawberry-3.141

                        Any ideas where i can start? like where i can get the name and status.

                        strawberry 3.141 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 2
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy