Offline editing of apps/device drivers

I'm not a coder and wouldn't know where to start so for me this is a non-starter.
It did get me thinking though.
Are you downloading someones driver/app code, amending it and using your new code?

If so, could you be breaking the terms of the license of the code?

Like I say, non-starter for me be it does raise questions for me and just thinking out loud.

1 Like

I don't see how it breaks any licenses.

It really just lets you edit code outside of hubitat (so you can use your own editor instead of the built in web editor).

It's also (for me at least in my first few hours of using it) a much faster way to write code (external editors have lots of complex features to speed things along).

1 Like

OK. Fine.
I was just asking the question as to whether you could be.

If your not, your not. :thinking:

1 Like

I think you can sort of do this now, albeit not automated. I have copy/pasted apps and drivers into a simple text file, and can pretty plainly see and edit everything (if I knew how to really do Groovy code). It only takes a moment to copy and paste.

But I think the broader question is why you think you would need to do this often, if at all? Especially doing it automatically. Most drivers and apps on here are fairly decent, and the authors are often open to modifying or adding features that have been requested. You really shouldn't have to be bulk modifying things.

I also think you may run afoul of licensing if you aren't careful.

Hmmm This is the second person to comment on licensing so either I'm not explaining what it does or I completely am missing something.

  1. This is only intended for people who are doing development. If you don't write custom drivers then this is of no use to you. Copy and paste works fine until you do it 25 times an hour and then it gets old.
  2. I don't think there is a licensing issue because this doesn't enable anything new. It just makes it easier to use an offline editor. 100% of what you are editing is also available on the hub, I'm not exposing anything new....

Maybe you aren't explaining the use case very well? I guess I don't understand what you are trying to accomplish?

To me, that sounds like taking an existing driver of some sort, modifying it, and reuploading.

I am not a developer so I probably shouldn't interject too much, but it seems like if this was an issue, some developer would have created something by now. Smartthings has been around forever, and Hubitat for a couple years or more, so I think there would already be this tool if needed.

If you are truly creating new code, and trying to distribute it or easily upload it, then this is exactly what the Package Manager does unless I am missing something here?

1 Like

There isn't, Not that I can see anyway.

1 Like

I've been so on the fence about this. I do a crap load of development in HE. Every driver and every app has been written by me and sometimes even rewritten as I look at the older code and see better ways of doing it. The only app on my system I haven't written (or attempted to rewrite) is the dashboard app.

That being said, I've never though to use an external editor. I like clicking save on one tab and refresh in the other quickly for testing. I feel like offline development would slow my work flow down.

However, offline may offer other features such as version backup and automatic code inserts (for things like common methods). It would also allow me to use an environment that I am familiar with.

I do like where you are going with this though and am watching I just can't make up my mind.

PS, no licensing issue that I can see. Especially if you are using it on your own code. If its somebody else's code it may be a problem if you start to distribute it and I think even that depends on the license used. But I'm not an expert in that field.

1 Like

I must admit this was what I was thinking when I first read the post, hence my first post.
Taking someones code, editing it and re-posting.
If it's not that then as has been said, probably not an issue.

1 Like

This was how I understood your original post (more or less: app or driver development). I used to edit my code with Hubitat's built-in IDE, but for anything of significant size, it's not ideal. I've switched to doing most of my development in VSCode (still doesn't seem to work 100% well with Groovy but is usually pretty good about figuring out code structure and helping me navigate it more easily, offering sensible completion suggestions, and allowing things like split-screen editing and Git integration).

My current solution is copying and pasting back into Hubitat, hoping I get the right app/driver page each time, especially if I'm working on something with lots of parts like CoCoHue (app and lots of drivers). For smaller projects (e.g., a single app/driver), this isn't that bad but still annoying to have to do all the time, and sometimes my brain forgets to copy/paste and wonders why the change I just made didn't seem to work... :laughing:

So: I think this is a great idea. I understand the use case (if anything to the point of not understanding what the alternative idea above is...if you have something in Apps Code or Drivers Code, then from a technical standpoint, you edit it, whether it's in the built-in editor or not, and most licensing doesn't forbid that but may forbid distribution; this does not change that technical aspect). I just don't know what unofficial method HPM is using to get these pages from the hub, but you must have figured it out. I'll try to check it out myself and see if I can get it to work for me, and I appreciate you sharing something like this!

1 Like

Be aware that it's pretty rough right now... It has worked great for me in the last few hours but I know exactly what I'm doing.

expect a lot of iteration in the next few days until I'm a little happier with it...

@loghound great initiative and that you got some attention to this :slight_smile:

I did not see this thread earlier, but now that I do, I want to mention that I have done what you're talking about. I work with VSCode and auto-upload my code from there using Python-classes I wrote. I've mentioned this in the forum before but there was never any interest, but since there seems to be interest now, I'll link to it again.

This tool takes a bit to setup and was designed for how I work and it does do more than just upload code. It also takes separate pieces of code and lets me reuse them in multiple Apps and Drivers. The closest we get to come on this platform to having private libraries we can include without actually having them.
It is for developers and requires a bit of understanding of what is what. It is also currently part of my driver and app repo since I'm the only one using it anyway. If there was interest that could possibly change.

Hi @markus

what you did looks like it's pretty complete -- is there any documentation or getting started?

I only did my thing out of desperation and while I've been slowly enhancing it I'd happily to something more complete (which I suspect yours is!)

(edit - I've been browsing the code -- it looks quite extensive and exactly what I was hoping existed! I'd love to a quick howto or readme)

-john

1 Like

It is rather complete, but there's no documentation since as far as I know no one besides me use it. The closest you come to documentation is to look in the file "hubitat_codebuilder_tool.py". That is the file being called. The entry I have in my launch.json looks like this:

{
            "name": "Python: hubitat_driver_helper_tool.py",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/tools/hubitat_codebuilder_tool.py",
            "console": "integratedTerminal"
        }

At the bottom of the python file there is a check to see if the empty file "DEVELOPER" exist, just to make sure anyone using this actually got to the bottom of the file. :stuck_out_tongue:

It would probably not take too much time to re-package this as a library, but do take a look at this and I'm sure you can follow it. All the real functionality resides in classes called from "hubitat_codebuilder_tool.py".

To add a new App or driver, set the ID to 0, once it has been created on the hub, just enter the ID into the configuration map and it will be updated on each run.

Main features:

  • Checks for and keeps a logged in session with the hub.
  • If a logged in session gets to be stale, it logs in again.
  • Only sends the code for an app or driver if the checksum has changed from the last successful upload to the hub.
  • Separate checksum and app/driver id per hub.
  • Separate checksum per github branch
  • Can re-use code to insert into multiple Apps/drivers
  • Generate App and driver lists as well as Hubitat Package manager manifests.
    • a bunch more I forgot I added

If you can with what I've described here write a quick howto for developers on how to use this I could start a thread for this with a Wiki post where anyone can add to the documentation. What do you think?

To get started I would recommend to make a copy of the tools folder and place it in you project, then make your own "hubitat_codebuilder_tool.py" file and configure it to do what you need using my file as a template.

Ok -- Thanks... I've slowly been digging in... hopefully I'll have a getting started guide or readme by this weekend....

1 Like

Watching this with interest... :slight_smile:

You guys see the github announcement about codespaces?

1 Like

No, not yet, but it wouldn't really help with this. We need it local anyway.

I realize this isn’t local but could you not use Codespaces to create/update your github code and then update hubitat using the import url?

Sure, but I wouldn't see that as something fast enough when developing. I also wouldn't want every piece of trial code in my git commit history. Messy. For that I could also just have a local webserver serving the folder I have my code in locally.