MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    SmartThings

    Scheduled Pinned Locked Moved General Discussion
    28 Posts 5 Posters 11.7k Views 6 Watching
    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.
    • cowboysdudeC Offline
      cowboysdude Module Developer
      last edited by

      Does anyone here have any experience with getting data from SmartThings api? I could use some help… Thanks!

      1 Reply Last reply Reply Quote 1
      • buzzkcB Offline
        buzzkc
        last edited by

        I’m currently setting up my MM and was looking for a smartthings module, looks like there is MQTT module, but I’d like to hit the api directly. I saw there is a nodejs sdk (https://smartthings.developer.samsung.com/docs/tools/sdks.html). I’m new to node, so not sure I’ll be of much help, but what are you looking to do.

        Darren

        My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

        1 Reply Last reply Reply Quote 0
        • cowboysdudeC Offline
          cowboysdude Module Developer
          last edited by

          I’m trying to learn to communicate with pretty much anything that I have set up with SmartThings… currently my thermostat is controlled by it but I’d like to learn how to manipulate that. I’m thinking if I can get that one thing to work then I can pretty much control anything else I have using SmartThings.

          I just read there and pretty much get lost…

          1 Reply Last reply Reply Quote 0
          • buzzkcB Offline
            buzzkc
            last edited by

            Yeah, The framework of it can get confusing. From what I’ve gathered you make requests for devices based on their capabilities (i.e. presenceSensor, lock, switch, temperature sensor, etc). Or if you have the device, you can then list what its capable of and get variables of those properties.

            Darren

            My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

            1 Reply Last reply Reply Quote 0
            • cowboysdudeC Offline
              cowboysdude Module Developer
              last edited by

              Well if I could even get that far I’d be happy LOL

              Is there an easier guide or example that you can think of that would help?

              johnnyboyJ buzzkcB 2 Replies Last reply Reply Quote 0
              • johnnyboyJ Offline
                johnnyboy @cowboysdude
                last edited by

                @cowboysdude

                Hey up Amigo…

                I use ST, along with WebCoRE, Automateit, Broadlink RM Pro and Mini (Blackbean) and a host of Alexa devices… and TinyCam Pro as the transcoder for my CCTV to display on Action Tiles… which I have on a 10" Tablet - as a control panel for all my Automation kit that controls about 90% of my home.

                Not sure if I can be of any help though, as Im sure you just want to use/utilise/grab the data onto/into MM? Much like what ActionTiles does with ST equipment eh?

                I thought you had already set up your whole automation as Tiles on your PC… iirc?

                That would be something else if you managed to get this onto MM… coupled with the TouchScreen overlay.

                The only 2 household items I have on MM are Sonos, and Hive… Sonos still works good… purely a visual obviously, but Hive is not so good, so kinda gave up on that on MM.

                At least with using ActionTiles (on a Touch screen), I have full control over everything, as well as using Alexa too of course, but having the Central control panel comes to it’s own for when guests are here and obviously do not know the voice commands - They simply use the Tablet.

                As said, not sure I can help out on grabbing the ST data for MM, but if you want any info on the above kit I use, then I am only too willing to tell you what I can.

                1 Reply Last reply Reply Quote 1
                • Mykle1M Offline
                  Mykle1 Project Sponsor Module Developer
                  last edited by

                  A johnnyboy sighting is like seeing Bigfoot. :-)

                  Create a working config
                  How to add modules

                  johnnyboyJ 1 Reply Last reply Reply Quote 1
                  • johnnyboyJ Offline
                    johnnyboy @Mykle1
                    last edited by

                    @Mykle1

                    😂😂😂… Hey up Amigo… How’s tricks?

                    I’m always lurking here … from time to time, to keep up with what you guys are up to 😉

                    Whenever our other Amigo posts a question like that, I can hear his brain cells clicking away, knowing something good is being worked on 😊

                    Mykle1M cowboysdudeC 2 Replies Last reply Reply Quote 1
                    • Mykle1M Offline
                      Mykle1 Project Sponsor Module Developer @johnnyboy
                      last edited by

                      @johnnyboy

                      Cool, nice to see you. Yeah, CBD is always working on something. I can’t keep up with him.

                      Create a working config
                      How to add modules

                      1 Reply Last reply Reply Quote 0
                      • buzzkcB Offline
                        buzzkc @cowboysdude
                        last edited by

                        @cowboysdude
                        When working in the IDE, remember that there are locations, usually a TestHub and Home, I have an additional smartthings in my shop, so you need to select the correct location before creating new device handlers and smart apps.

                        I’d start with deviceHandlers. I typically find the code on github for the device I’m looking to implement a handler for, then on the API IDE I’ll create the new handler from code (see: https://www.thesmartesthouse.com/blogs/the-smartest-blog/how-to-install-a-custom-device-handler-in-smartthings). Once you’ve published the handler for yourself, you can either setup a new device or if you want to modify a device (such as changing a door sensor, that has wire contacts, to act as a smoke alarm) you update it’s Type field to be the new handler. In your mobile app. you should see it change from a door sensor to a smoke sensor.

                        There are handlers that work in conjunction with smart apps also. Typically I copy the code for the new smart app the same way, and publish them to work for myself.

                        So as far as writing my first MM module, I was looking at this node library (https://github.com/hijha/smartthings-node) to act as the client for getting device data from ST. It requires a key to be generated. That key you will generate from the token generation page here: https://account.smartthings.com/tokens

                        I was hoping to get this created this weekend and play with it, but life got in the way, so hopefully I’ll get something working this week.

                        Darren

                        My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

                        cowboysdudeC 1 Reply Last reply Reply Quote 2
                        • cowboysdudeC Offline
                          cowboysdude Module Developer @buzzkc
                          last edited by

                          @buzzkc I know how that feels!! I don’t even think I can look at ST until almost winter in reality. Currently I’m working on a job that should take 4 months…they gave me 2 LOL After that the list is longggggggggggggggggg still… so I’m really busy.

                          IF you need anyone to test or help let me know!

                          1 Reply Last reply Reply Quote 0
                          • cowboysdudeC Offline
                            cowboysdude Module Developer @johnnyboy
                            last edited by

                            @johnnyboy trying… trying LOL Great to see you!!!

                            johnnyboyJ 1 Reply Last reply Reply Quote 0
                            • johnnyboyJ Offline
                              johnnyboy @cowboysdude
                              last edited by

                              @cowboysdude said in SmartThings:

                              @johnnyboy trying… trying LOL Great to see you!!!

                              As @buzzkc has stated about Device Handlers, and Im sure you have (Must have?) already done this… these can be found in the IDE, which are C&P from github.
                              There is a constantly updated list of DH’s on the ST Forum, so worth checking that out to compare with the devices you have, and wish to manipulate.

                              Me personaly, I use WebCoRE to do my manipulation… and If I need to add anything that is not the “Norm” then I would simply create a Virtual switch on the IDE, and then point towards that, with my chosen manipulation… and if you have used WebCoRE before, then you know it has limitless possibilities. Bad comparason, but I look at WebCoRE as IFTTT on Steroids :-)

                              Some things I do, requires using several items… like my door sensor for example - It opens (Trigger ) and it then informs ST… which then informs WebCoRE, whitch then informs EchoSpeaks to then go through Amazon, to speak my chosen text, on my chosen Amazon devices - “Warning, Side door has been opened… Alarm sequence will initiate in T-Minus 20 seconds”
                              I also added in another “Then” which will turn my chosen lights on @ 100%, until door is closed… and also to turn on my smart plug, which has a Siren attached, to activate after the 20 second time, also to start recording on CCTV in that location.

                              The lag on this is about 2 seconds… so not a real concern given the hoops it has to jump through beforehand.

                              I have only ever needed to slightly alter a DH once, for a Hive Sensor… but that was to simply change a 6second delay to a 12 second delay… purely because the original usage would be going through 1 loop, and I was going through 4, so need to extend the timeout.
                              I also have my Hive Heating controllable through ST of sorts, using ActionTiles and placing Hive on the screen there.

                              IF my MM was Touchscreen, and I had the time to work it out, I would have loved to be able to place several icons/Tiles (Virtual Switches) onto it, and control numerous ST devices from there… But I found it far far quicker, and easier, to simply use a Tablet… with the benefit that I can add several other tablets throughout the house, each with either control of that zone only, or the ability to swipe to another zone from the same screen… by creating a Link tile in every window to go to a chosen zone.

                              You could also create Media Tiles… showing a constant stream of several cameras… and make that Tile as small or as big as you like… I have Netflix/Amazon/Kodi/IPTV as tiles too, so one click, and it pops up for me.

                              And, as mentioned, it will aslo link to any app you have on the device you are using, by creating a link tile to it… which will open up for you directly in that screen/tile… and I find this usefull when playing music through my Sonos system, and can bring up the full library to choose from, and be able to control the speakers too.

                              I’m not sure by your OP that you are wanting to manipulate the data to then create something to use on the MM framework, or whether you simply want to manipulate the data just to alter things to your own suiting?
                              But if you have read anything above that you need any more info on, then ask away…

                              1 Reply Last reply Reply Quote 2
                              • buzzkcB Offline
                                buzzkc
                                last edited by

                                I’m finally starting to make some progress on this. I’ve been doing development in a docker instance and found editing files while the container is running corrupts files. :-)

                                So I have it connecting and bringing back device information at this point. I still need to parse that info. I’m working through the steps get all the info in the correct order to model it (get device ids>>get device components>>get device capabilities>>statuses etc.)

                                I do have two hubs and found that it brings back devices for all hubs, so I’ll need to get the hub info too.

                                Darren

                                My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

                                1 Reply Last reply Reply Quote 1
                                • cowboysdudeC Offline
                                  cowboysdude Module Developer
                                  last edited by

                                  This is something that I want to seriously look at this winter. Time right now is very hard for me to do anything…but I am keeping an eye on this and I appreciate ALL the input!!!

                                  I am trying first to get my thermostat to work via the mirror… module form. I can do it other ways but I want to learn how to use this IDE. But it gets to be too much… but you both have excellent ideas that I will be picking your brains soon!!! :)

                                  Keep posting please!!

                                  1 Reply Last reply Reply Quote 0
                                  • buzzkcB Offline
                                    buzzkc
                                    last edited by

                                    I’ve made a little more progress on this, but nothing to display the device info yet. I found the node-smarthings library uses promises to return results, which I’ve not worked with specifically, so been struggling with tying the device information to the device capability status results. I think I’ve finally worked passed it, but still have some testing to do.

                                    I’ve been trying to pass the device object from the first call to the call back function for the capability status, but not figured out how to do that. All of the status results were tied to the last device processed from the device callback. I did finally move the looping of devices to where only one device was sent to the socket notification that calls the capability status and seems to be working that way.

                                    Darren

                                    My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

                                    S 1 Reply Last reply Reply Quote 0
                                    • S Do not disturb
                                      sdetweil @buzzkc
                                      last edited by sdetweil

                                      @buzzkc so, with promises, you have a ‘then’, with a ‘resolve’ and an ‘error’ callback, and the resolve and reject methods of the promise can provide data to the resolve and error routines…

                                      just a reminder, the return new Promise() returns IMMEDIATELY… the function inside the promise is called async sometime (milliseconds) later

                                         function_name: function(parm1_in, parm2_in) {
                                           return new Promise( function (resolve,reject){
                                                   if( all_good) {
                                                       resolve(data_item)
                                                   }
                                                  else {
                                                      reject(error_data) 
                                                  }
                                           }
                                           )
                                      
                                      

                                      then the method CALLING this function

                                          function_name(parm1, parm2).then( 
                                                   resolve_func(data_item){ },
                                                   error_func(error_data){}
                                          )
                                      

                                      a working example , using the arrow function (parm) => {
                                      the arrow function insures that the data context of the outside caller is maintained,
                                      where as function(parm) { does not (u had to use the ‘self =this’ thing

                                      let promise = new Promise(function(resolve, reject) {
                                       if(!setTimeout(() => resolve("done!"), 1000)){
                                           reject("settimeout_failed")
                                       }
                                      });
                                      
                                      // resolve runs the first function in .then, reject runs the second function
                                      promise.then(     // this will block until the function inside the promise call resolve or reject
                                        result => alert(result), // shows "done!" after 1 second
                                        error => alert(error) // doesn't run .. this will never occurr as settimeout never fails. 
                                      );
                                      

                                      Sam

                                      How to add modules

                                      learning how to use browser developers window for css changes

                                      1 Reply Last reply Reply Quote 2
                                      • buzzkcB Offline
                                        buzzkc
                                        last edited by

                                        Thanks Sam, That does help explain things. The grandkids are visiting, so will be a day or so before I get back to this, unless I just can’t sleep tonight. ;-)

                                        Darren

                                        My Build: https://forum.magicmirror.builders/topic/11153/new-non-mirror

                                        S 1 Reply Last reply Reply Quote 0
                                        • S Do not disturb
                                          sdetweil @buzzkc
                                          last edited by sdetweil

                                          @buzzkc no problem… i’ll be around

                                          also, the function in the promise can also be arrow

                                          return new Promise(  (resolve,reject) =>{
                                                      if( all_good) {
                                                           resolve(data_item)
                                                       }
                                                      else {
                                                          reject(error_data) 
                                                      }
                                                   })
                                          

                                          Sam

                                          How to add modules

                                          learning how to use browser developers window for css changes

                                          1 Reply Last reply Reply Quote 1
                                          • S Do not disturb
                                            sdetweil
                                            last edited by sdetweil

                                            and you can nest calls to functions that return Promises.

                                               call_function_a(parm1, parm2).then( resolve_function(resolve_parm){ 
                                                             ... processing
                                                              call function_b(resolve_parm).then(resolve_function(some_otherdata){
                                                              ....     processing
                                                              })
                                               })
                                            
                                            

                                            the 1st call_function_a routine will return a Promise object immediately
                                            and when the function inside the promise resolves, then ‘.then (resolve’ function will be called.

                                            the ‘.then’ waits

                                            you can also split it up and wait later

                                              var p =   call_function_a(parm1, parm2)
                                                 processing
                                                 processing
                                              Promise(p).then (... etc)
                                            

                                            i have a piece of code that loads a list of images from multiple difference sources, and knowing these take a ‘long time’ I wrapped them in promises… and start multiple at the same time…

                                            now I have a list (array) of promises… but need to wait for all of them to complete (to have the complete list of images)

                                            Promise.all(list).then(() => { sort full list of images, note that resolve() can't send back the list as its not complete }
                                            

                                            you can also wait for one

                                            Promise.race(list).then( ... etc)
                                            

                                            Sam

                                            How to add modules

                                            learning how to use browser developers window for css changes

                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy