FAQ: Github Integration How to Add and Update from Repositories


(Jason) #1

I couldn’t find a good/in-depth FAQ for a GitHub How to with ST so here goes:


If you’re looking for uk integration:


Please, I am by no means an Expert, If you find an error or see something that I should change let me know and I will update it.

Log into the IDE @ https://account.smartthings.com

Enable and Link your GitHub Account: Section taken from Smartthings developer docs

Step 1 - Enable GitHub Integration
Click the Enable GitHub Integration link on the My SmartApps or My Device >Types page. This will launch a wizard that will guide you through the process.

Step 2 - Connect your GitHub Account to SmartThings
On Step 1 of the wizard, follow the instructions to authorize SmartThings to integrate >with your GitHub account. Click the Next button after you have done this.
Source for Enabling GitHub Integration



For most of us we won’t need to go any further in the developer documents integration.

To add a repository Please do the following:
Click on My SmartApp or My Device Handlers Sections.
Click on Settings you will see the following popup:

Click Add new Repository and enter the following information:
Owner (your username will default here just override it)
Name
Branch

Then click save.

See this example of info below:

After adding a repository you will see that in your smart app or device handler sections are color coded.

Black
Indicates that the file is unchanged between your forked GitHub repository and the IDE.
Green
Indicates that the file is in the IDE only, and not in any repository.
Blue
Indicates that the file exists in your GitHub repository, and has been modified in the IDE but not committed to the repository.
Magenta
Indicates that the file has been updated in the repository, but not in the IDE. To resolve this, you should click the Update from Repo button, where you sill see the file appear in the Obsolete column. More information about the Update from Repo button can be found below.
Red
Both the IDE version and repository version have been updated, and are in need of a conflict resolution. To resolve this, you should click the Update from Repo button and follow the steps there (more information about the Update from Repo action can be found below).
Brown
Indicates that the SmartApp or Device Type is unattached to the repository version. Typically this happens when a new SmartApp or Device Type is created from a template, and the name or namespace hasn’t been changed. If you update from the repo without changing the name or namespace, the IDE version will be replaced with the repo version. Typically in this case you would change the name and namespace to be unique for your code.
Source ST developer Documents

Seeing that my rule machine Smartapps are Magenta, I know that I need to update them.


Click the update from repo button, then select the repository you would like to update from. In this case I would select Rule Trigger (master)


The following will pop up

Left Column: Everything that is available to update that is Currently Installed is in the and should be checked.

Center Column: If you see anything here you might be on a forked copy, or have Altered the code. It will have an option to compare the code between the two copies. When I initially set up my integration I knew nothing about any of this, I somehow forked rule machine and could not update it from @bravenel’s repository. The fix was to delete the smartapp completely then add it straight from his repository.

Right Column: these are things that aren’t currently installed from the selected repository. You can check these and update/install them all together if you wish.


Check the Publish Button to Publish for me, I believe this is necessary for Rule Machine, I don’t know if it’s necessary for everything…

Lastly Click execute Update and they should update/install/publish(if checked)

While executing this example I selected the image files in the repository, and received an error in the IDE after clicking execute update. I believe that will happen with anything other than an app or device handler file.


Continuing the discussion from GitHub integration and Smartthings:


Help with github integration
Github vs Manual installation of SmartApps
[RELEASE] Device Monitor - Get Notified if Devices Stop Reporting
Bloomsky Weather Station
Writing code
[RELEASE] D-Link Camera Manager (Connect) - Add your D-Link IP Cameras to SmartThings! Video Streaming, Image Capture, Motion Detection and more
[RELEASE] Simple Device Viewer
[RELEASE] Super Notifier - All your alerts in one place!
Proper way to use other's DTH's & Smartapps through GitHub?
Schlage BE469 Camelot Zwave ongoing issues and questions
Sensi Thermostat
[RELEASE] Super Notifier - All your alerts in one place!
What does the different color text mean?
[RELEASE] Stelpro releases its Ki ZigBee Line-Voltage thermostat: the STZB402+
Ide Colors
[UPDATED SEPT 2018] Hue B Smart (Groups & Scenes) - Remove Popcorn Effect!
Adding Device Handler from Git hub for non dev
[BETA] Lutron Caseta Integration using Raspberry Pi (Pro or Standard Bridge) [DEPRECATED--See new Release thread instead]
Bloomsky Weather Station
[RELEASE] Lock Manager
[DEPRECATED] EchoSistant Version 3.16 with Alexa Feelings
[RELEASE] Generic Video Camera DeviceType, Yes, Live Video Streaming
[RELEASE] Resilient - My Ecobee Device & ecosystem v5 - The smartest thermostat under ST with new "comfort tips" features and Unique Integration with Echo/Ask Alexa
Help with CoRE not triggering correctly
[OBSOLETE 1.1.6 5/25/16] Big Talker - Talk when events occur
[UPDATED as of March 24, 2016] Hue Lights & Groups & Scenes (OH MY!)
Complete Instructions to install Rule Machine & GitHub into IDE [DEPRECATED]
Update DH code after it has been installed
Rule machine - as per the app developer, this app is no longer available for new installs, distribution, or support
[Release] [Closed] Google Assistant Relay V1 - Google Home Audio Notifications!
[Deprecated] Thinking Cleaner 2.x (Roomba Control)
Maybe I don't need Rule Machine after all
Blink: wifi camera/motion sensor on Kickstarter
Rule Machine install help into IDE
Writing code
Minor update to "Photo Burst When" to add button support
[RELEASE] Aeon Labs Aeotec Doorbell
Working MIMOlite Device Type with Sensor
Where to start - Checking the status of two or more "things" before triggering an action
New App: Vacation Light Director
My device handler color coding question?
Android as a Speech/Alarm Device released! And Updated!
[RELEASE] Leviton Decora Z-Wave Plus Dimmers (DZ6HD & DZ1KD)
[RELEASE] Leviton Decora Z-Wave Plus Dimmers (DZ6HD & DZ1KD)
D link dcs-942l for dummie?
[RELEASE] D-Link Camera Manager (Connect) - Add your D-Link IP Cameras to SmartThings! Video Streaming, Image Capture, Motion Detection and more
(Different Computers. So happy with Indigo.) #2

Thank you for this. I had become curious about making this work and you just saved me some head scratching.


(DavidK) #3

Hello, is there an issue adding repositories today?

I was able to add one repository yesterday, which was my first.

But today it does not seem to work, or maybe I am doing something wrong?

Not sure. I think I follow the instructions for adding rule machine and it does not seem to find and link to the repository.


(Jason) #4

Did you have rule machine installed before adding his repository?

If so try uninstalling them, and add his two smartapps straight from the right column of of his repo. Make sure to have the publish button checked before hitting update.


(DavidK) #5

I was able to add rules now. No problem. Not sure what the problem was before.

Then I tried twack/smarthings-apps

It finds the repository, but shows no apps available.

Same thing with Sticks18 for the hue button controller app, shows no devices in the devices list.


(Jason) #6

Hmm, I don’t have either of those repo’s i’ll install them in a bit to see what i can find out.

In the mean time I noticed that all of my pictures are ridiculously small and hard to read. I updated the picture of that shows @bravenel Rule machine repo properly entered (and it’s legible now!)


(DavidK) #7

Okay, statusbits repository works.

Not sure, if there are some problems with some repositories or I am doing something wrong.


(Jimmy) #8

Thanks! For those of you that don’t even have a GitHub account, you have to first create the account and then create a repository names SmartThingsPublic.


(Jason) #9

Good point I’ll write it up and add it when I have time.


(Michael Hess) #10

I lost my github integration, I just get the enable github button now. Tried on a different browser and PC thinking it was a cache issue but same thing happens.

Any thoughts on how to get this working again?


(Rick S) #11

When I select Enable GitHub Integration from the IDE, it brings me to the page with the link, when I click on the link, it gives me a Page 404 error with a search box, if I enter SmartThings, it returns some +1200 repositories

The original instructions don’t work for me at all as I don’t see a wizard after selecting Enable GitHub Integration from the IDE

Rick


(Nate) #12

Thank you for this. It is very helpful! I don’t see what you describe here. I’m assuming I have to have added a smartapp or device. Is there a thread for how to add custom code? I’ve seen many that discuss it, but very few actually give specifics on “how to” that I can find.


(Jason) #13

(Allen Crawford) #14

Warning, I’m not a developer or Github expert, so this could be a very dumb couple of questions. But here goes anyway. I have the Github integration seemingly working BTW, but there are still a couple of things I don’t quite understand.

If I’m not developing any of my own SmartApps (currently true) then why do I even need to fork the main public SmartThings Github repo in the first place? Unless a forked repo in Github automatically stays up-to-date from the public repo I forked, then it seems like me using this forked repo would just lead to the SmartApps I consume being very out-of-date unless I also add to the IDE each individual developers’ own forked SmartThingsPublic repos where they are presumably updating their code. But that seems very inefficient assuming they are also pushing their changes upstream to the main repo. And if they aren’t doing this, then what’s the point of the main repo exactly? Basically, I’m just confused why I even need to have my own Github repo if I’m not writing any code since it seems that the SmartApps are either in the main public repo or some individual developer’s Github repo(s).

Also, I skipped the steps of cloning my forked repo because the documentation says it is optional and I (at least for the foreseeable future) don’t plan on debugging a lot of code or writing my own. However, the bolded part of those instructions concerned me a bit:

From docs.smartthings.com:
While not required to for submitting changes, this is useful so that you have a local copy of the source code (useful for grepping the source locally, using your favorite editor, etc.), and is required to update your fork from the main SmartThingsPublic repository.

Does that mean my forked copy will never get updated from the main one? Do I even care if I’m already adding individual developers’ Github repos to the IDE as well as the main public one?

I hope this all makes sense and thanks in advance!


(Jason) #15

It’s up to you whether or not you wish to fork the smartthings github repo. I did not write the docs.smartthings.com article, Step 2 was all that was “necessary” authorizing them to connect to your GitHub account.

Nope, If your using a Stock device type or smartapp you are better off adding it through the app or changing it to the smartthings device type in the ide as I believe those do auto update. Anything added through GitHub integration will require you to periodically check to see that your up to date using the color chart in the docs. The benefit of it is for an app like Rule Machine where there are tons of updates, you can easily check to see that your up to date and with 1 click get up to date vs having to copy and paste code into the IDE.

Again only step 1 and 2 were meant to be in my instructions thats why I quoted them, but I will put a note in OP in a bit.

Personal preference, Again the benefit is that you can quickly check to see if you have the current version without bugging each developer. Also it gets rid of copy and pasting turning it into a button push instead.

Hope that helps answer your questions!


(Allen Crawford) #16

Thanks for all the answers. I actually posted this in the wrong thread (had too many open) by accident. I wasn’t asking you directly any of these questions, I was just trying to better understand Github integration in general. I meant to post this in the thread where they announced the initial integration, so I might go re-post it there.

Regarding the “forked repo in Github automatically stays up-to-date from the public repo I forked” note, I was really just referring to Github only, not keeping my IDE up-to-date. Definitely understand that I have to update everything I install from Github manually myself, but yes, way better than copy/paste.

That said, I just chatted with a developer-type friend of mine that actually uses Github, so I think I understand it all now. I was just confused why anyone would fork the entire public SmartThings repo if they just wanted to add their own SmartApp since it makes it confusing in the IDE when you have to filter through the entire list of SmartApps in that particular developer’s forked repo to fine the one app you care about. Seems like doing what “bravenel” does with Rule Trigger makes more sense to me. But then I guess that repo doesn’t have the necessary relationship with the main SmartThingsPublic repo that you’d need if you ever want your app published there (a process I know nothing about yet).

I’ve also learned that you can rename your forked repos in Github so that they aren’t all “SmartThingsPublic” which makes things extremely confusing when you go to “Update from Repo” in the IDE and have several duplicately-named repos. But it would be cool if SmartThings would just add a label inside the repo settings so we could name them whatever we wish for clarity’s sake.

Thanks again!


(Jason) #17

Do you mean Can’t?

If you can, Please share =D


(Allen Crawford) #18

You can rename them within GitHub itself. Just log into github.com, go to your repository in question, click the “Settings” tab, then right at the top you can give it a different name. I had assumed doing this would break the integration with the SmartThings IDE, which would be really bad for people with popular public repos, but it actually doesn’t seem to do that.

I added my repo a second time to see if it would let me have them both and it did. I even added a SmartApp via the “Update From Repo” button with my old name (it worked) and then went to add from the new and it no longer had that app listed, proving that it is connecting to the same repo. I’ve renamed it a second time and strangely the old names still work even after if I deleted them from the IDE Settings and attempted to re-add them. So apparently I’ve got three valid repo names now. Not sure how long that’ll stick. Here’s an example where the first two are my own single, forked repo:

But, having a label inside the IDE is clearly even better since I can’t force other people to rename their repos.


[RELEASE] Device Monitor - Get Notified if Devices Stop Reporting
(Allen Crawford) #19

Follow up, just found this page that confirms the behavior I’m seeing in the IDE.

https://help.github.com/articles/renaming-a-repository/


(Jason) #20

This is what I was looking for, I thought you meant in the ide for others. Your right that it would be helpful for St to add a custom tag box that we could name in ide