[RELEASE] Hubitat App/Device Code Update Manager

I updated my post...

git init

isn't needed for Clone. I think it's likely I tried Checkout first... and then just blended the steps.

I'm a programmer too, but it's still a bit of a mind reading trick to determine how each creator of an app/package uses Node.

Because this is new, cloning github is acceptable BUT my reason for writing was to help others who didn't have as much luck with the mind reading trick. :smiley: :smiley:

I assume, that like most, at the right time, you'll publish to NPM and then the instructions will be familiar to non-programmers, who might have already setup Homebridge.

This is the first time I've released a project with such a wide profile of user types so it would be helpful for me to understand what users are used to setting up, especially non-programmers.

Do you have any suggestions or example projects you can link me to to refine my release? Would publishing to NPM be a good first step? What details are helpful in a publish and what could be clearer in my README?

Most HE users know how to install drivers/app and should be pretty comfortable with it. However once you start talking about setting up a node server or docker a number of them will start to feel intimidated.

That being said, this project is interesting for a lot because it adds a highly wanted feature. If you know groovy you should be able to convert it over into a native app. It seems to be pretty much reading/parsing the html. I haven't dug into the actual updating code to take a look at how it works though.

I wanted to see if it was possible and created a method to grab the app list by scraping the html and was able to put this together. It creates a map of the installed app code. I use regex to parse the data, there may be better ways but this was more of an experiment. It could easily be modified to get the driver list and probably other api calls that you use to check and update the codes. But maybe somebody will find it useful and run with it.

def getAppList() {
    def params = [
    	uri: "http://${location.hubs[0].getDataValue("localIP")}:8080/app/list",
        textParser: true,body: [:],headers:[:]
      ]
    try {
        httpGet(params) { resp ->
            log.debug "response.status: ${resp.status}"            
            state.appList = []
            def matcherText = resp.data.text.replace("\n","").replace("\r","")
            def matcher = matcherText.findAll(/(<tr class="app-row" data-app-id="[^<>]+">.*?<\/tr>)/).each {
                def href = it.find(/href="([^"]+)/) { match,h -> return h }
                def title = it.find(/title="([^"]+)/) { match,t -> return t }
                state.appList += [title:title,href:href]
            }
        }
    } catch (e) {
        log.debug "e: ${e}"
    }
    return state.appList
}
2 Likes

I had considered building a native app, but I really wanted to get a proof-of-concept working first to see if I could indeed hit the hub REST APIs to do everything I wanted. I'll have to put together a proof-of-concept native app to see if such an app would work well. Things I'd want to validate are:

  • Make requests to GitHub to download source for comparison
  • Make requests asynchronously and show loading indicators for each row
  • Make AJAX requests on button click without reloading the page

If anyone has done either before, I'd love to know your experiences with it.

@xamindar @Angus_M @bptworld After much effort and headache, I've managed to compile native apps for Mac and Linux. I'm still troubleshooting the Windows compilation, but I hope to have that working soon. You can download and try out the standalone app release here: Release v2.0.0 · richardpeng/hubitat-update-manager · GitHub

4 Likes

Have it up and running on my Chromebook! Now to play around a bit.

Thanks!

1 Like

I installed the hubitat-update-manager_2.0.0_armhf.deb on one of my PIs. Works, I have a few questions.

--Where does it get the import url from? All except one of my apps show "No import URL found". Since one of them is showing an update I assume either some apps have been hardcoded with the import url or it somehow "knows"? Some of my appcode has the import url listed in the code as "importUrl" but it's not getting it for those ones.

--Is there a way to get it to remember my hub? Every time I open it again I have to specify my hub url again. It is remembering the custom import urls i entered, just not the hub for some reason.

--is there a way to launch it headless?

--is it just me or is it showing updates for stuff I already have up to date?

Anyway, pretty cool. Thanks for this.

EDIT: I am manually adding the import urls. Works fine for the apps page, but the drivers page does not allow me to add them. Dialog comes up, I paste the url and hit save, and it goes right back to "No import URL found".

The import URL comes from the Hub. My app is only able to check for updates on apps/drivers that retain their import URL after you save the code. I believe that's what this separate thread was partially about. I think code has to have a certain header for Hubitat to recognize and save the import URL.

I haven't added that feature yet.

That would be running it using Docker or Node.

Edit: sorry I misunderstood. That's a good idea. I may consider creating a command line interface for it at some point.

Your code needs to be exactly the same as what's in the import URL, including whitespace. It doesn't hurt to click the update button to make the code match exactly. If you've made modifications to code, the update button will replace any modifications with the latest code from the import URL.

Your website needs to have certain code to allow the Import function to work properly if you are hosting your own groovy files.

In my case I needed to edit my .htaccess file to allow CORS (instructions for this vary by type of web server) and have it recognize .groovy files as plain/text type. My stumbling block for some time now turned out to be that I had listed "groovy" when I actually needed to have ".groovy" as the extension...

Thanks! That clarifies things.

Any idea why I can't save import URLs on the Devices page? Is anyone else having this issue?

1 Like

I’m having this issue as well.

So I'm not sure why, but this reported my Inovelli drivers need to be updated, but I know they are current.

Wonder if there's something like white-space is making the code not match?

Mismatched whitespace will also make the driver say that it needs an update. You can just click update and it'll stop saying that it needs an update until the driver actually needs an update.

Edit looks like I posted it to the wrong person and thread.

1 Like

Got this error.....any suggestions?

>
TypeError: Cannot read property 'childNodes' of null at parser (/usr/src/app/.next/server/static/AIx5MgUxJTpk0P9hcEeFn/pages/api/hub/details.js:191:127)                                                                    
    at processTicksAndRejections (internal/process/task_queues.js:97:5)                                                       
    at async module.exports.GsQR.__webpack_exports__.default (/usr/src/app/.next/server/static/AIx5MgUxJTpk0P9hcEeFn/pages/api/hub/details.js:123:15)                      
    at async Object.apiResolver (/usr/src/app/node_modules/next/dist/next-server/server/api-utils.js:51:9)                                                                 
    at async Server.handleApiRequest (/usr/src/app/node_modules/next/dist/next-server/server/next-server.js:434:9)                                                         
    at async Object.fn (/usr/src/app/node_modules/next/dist/next-server/server/next-server.js:355:37)                                                                      
    at async Router.execute (/usr/src/app/node_modules/next/dist/next-server/server/router.js:117:32)                                                                      
    at async Server.run (/usr/src/app/node_modules/next/dist/next-server/server/next-server.js:475:29)                                                                     
    at async Server.handleRequest (/usr/src/app/node_modules/next/dist/next-server/server/next-server.js:131:20)

How are you running it? What command did you type?

docker on a synology

Can you give me any more specific details on how you got the error? Not sure how to help you otherwise.

I installed and it's running on http://localhost:3000

It can load the hub details using the 'hub' link, but when I click Apps or Drivers it just sits and spins. The underlying error I see in terminal is as follows:

FetchError: invalid json response body at http://10.0.0.152/driver/ajax/code?id=index reason: Unexpected token < in JSON at position 0
at /home/pi/hubitat-update-manager/node_modules/next/dist/compiled/node-fetch/index.js:1:52179
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
at async Hub.get (/home/pi/hubitat-update-manager/.next/server/pages/api/hub/details.js:270:17)
at async module.exports.lpBF.__webpack_exports__.default (/home/pi/hubitat-update-manager/.next/server/pages/api/drivers/[id].js:138:15)
at async apiResolver (/home/pi/hubitat-update-manager/node_modules/next/dist/next-server/server/api-utils.js:8:1)
at async Server.handleApiRequest (/home/pi/hubitat-update-manager/node_modules/next/dist/next-server/server/next-server.js:48:397)
at async Object.fn (/home/pi/hubitat-update-manager/node_modules/next/dist/next-server/server/next-server.js:40:176)
at async Router.execute (/home/pi/hubitat-update-manager/node_modules/next/dist/next-server/server/router.js:23:67)
at async Server.run (/home/pi/hubitat-update-manager/node_modules/next/dist/next-server/server/next-server.js:49:656) { 
type: 'invalid-json'
}

Any advice?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.