FAQ: Github Integration How to Add and Update from Repositories [OBSOLETE]

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:

13 Likes

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

1 Like

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.

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.

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.

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!)

Okay, statusbits repository works.

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

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.

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

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?

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

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.

2 Likes

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!

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!

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!

Do you mean Can’t?

If you can, Please share =D

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.

1 Like

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

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

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