How to share AI built drivers?

Just curious if anyone else has built device drivers using AI, and how to best share with the community?

I don't code, so I recently had Grok build me a custom device driver for controlling my Midea portable AC via Matter. Per other post recommendations, I was using the built-in Nest and Meross Matter Thermostat drivers with some success, but the temp reading was off and I was unable to control them using a Dashboard tile.

So far the new custom driver seems to work. I'd like to be able to share it so others can benefit and possibly improve on it, but not sure how to make that happen?

1 Like

Typically, community developers will upload their code to a hosted platform meant for code sharing and collaboration (and version control, though this is rarely used by anyone but the developer in this context). GitHub is probably the most popular, but there are alternatives like GitLab or Bitbucket -- or really any site capable of serving a plain text file (all the code you share ultimately is) would technically work.

You can also just share your entire code in a post here. Formatting it as code by enclosing it in lines containing three backticks, ```, provides better formatting than just pasting the raw text, for example:

```
your code here
```

As an aside, I would caution against sharing an entirely AI-built driver. I have seen many in the community recently, and there are often unusual problems with such code. It can be a helpful tool but, IMHO, works best when supervised by a knowledgeable eye to verify the output. If you do not have this knowledge from writing Hubitat apps and drivers already, it may be helpful to ask others to review your code beyond just sharing it as-is, or consult the developer documentation so you can learn to do this yourself. Good luck!

4 Likes

There is a forum size limit on posts, about 65,000 characters, so some code will be too large to post.

All fair points—thanks for the thoughtful caution!

One goal of my post was to ping Hubitat staff: as AI empowers more non-coders, we’ll need a clear path for sharing and vetting these drivers/apps.

My prompts were exhaustive (dev docs, tech sheets, protocol specs) with weeks of beta testing and revisions—no issues after a month of daily use. Still, I agree quality control matters.

A structured review process could turn this trend into a real win for the platform and community. Excited to see where it goes!

1 Like

I'm using the HA Midea local wifi integration, and HADB, for my Window U-Split unit in Hubitat.

The HA integration gives me control of everything, and even the indoor and outdoor temps it is measuring. It has been spot on. I'm reading that what is exposed by Matter for these units is very limited, is that what you are seeing?

Google:
"more advanced features such as specific fan speeds, fan modes (e.g., Auto, Eco), and swing adjustments are not yet exposed by Matter"

You might want to play with AI for creating a Hubitat local wifi driver, to gain access to more features than Matter gives you.

A many decades software engineer, architect, and a security guy with a very high standard of quality expectation speaking, also someone who has managed a team of software engineers...

I think the concern with AI written drivers is maybe overblown. Possibly WAY overblown. AI is no worse than some person who is not the best software engineer writing a driver. AI is both not a magical bullet nor the worst possible software developer you've ever seen. The quality of your AI written code largely depends on your strength as a prompt writer (or "prompt engineer"). It also depends on your own understanding of writing code and more importantly testing and debugging stuff as sometimes you have to jump in where AI falls apart.

To that end, there need be no "policy" on AI written drivers (or apps) apart or separate from human written drivers or apps. If there is to be a policy on what is acceptable then make it a technical policy. Eg a driver must have a test harness that does X, Y and Z. It must have documentation, so on and so forth. As ultimately most people will be unable to tell a human written driver or app from an AI written one. If you think human code quality is good, have I got some ocean front property here in Arizona for YOU!

As for how to release an AI written driver? the same way you would release a human written one. Host the code in Github assigning it a license of your choosing (Apache 2.0 or Creative Commons are really ideal) and then make a release post on the Hubitat community forum.

If you feel so inclined, accept feedback and work the AI interface to make improvements based on the feedback. It is really not hugely different the purely human managed code. AI can read and most likely understand the Hubitat developer docs better than you can.

I say this as someone who has used AI to develop code (and test harnesses!). I'm on the verge of releasing my own largely AI developed Hubitat app and custom personal weather station (PWS) dashboard. The big hold up I have at the moment has nothing to do with Hubitat and everything to do with how PITA managing CSS is across multiple platforms. I have a high standard (expectation) of quality and the current version doesn't meet it yet. The mechanics are solid. It's all about the display.

I also work in "big tech" and AI writes crap tons of code every one of you use every day now. The quality hasn't gone up or down as AI was trained on defective human code; it therefore writes defective code to human standards.

3 Likes

@Hush456 – congratulations on your success! :tada:

I can definitely relate. Often I’ve struggled to find native or community drivers that would allow me to add devices or virtual devices to my smarthome setup in ways that truly benefit our household. Like you, I found myself limited not by imagination, but by the realities of coding.

I freely admit—I am not a coder. In my career as a semi-retired Software Implementation Project Manager, I’ve had the pleasure of working alongside many ingenious developers. I even tried learning Groovy myself, but quickly realized that my limited Visual Basic community college background just couldn’t bridge the gap.

Then AI came along, and suddenly a new world opened up. I’ve written a virtual driver using AI for Hubitat, and I have to say—it was both challenging and incredibly rewarding. Like you, my prompts included functional specifications, device capabilities, and more. And yes… sometimes reading the AI’s output felt like corralling cats! :cat: Some responses left me scratching my head, thinking, “Why did you go there?”

After lots of alpha and beta testing, our household is now successfully using the driver. I was actually setting up a GitHub repository thinking about sharing my project when I came across your post. I had hesitated because, having built this in my own little bubble, I wasn’t sure what unintended consequences releasing it might have. So I really support the idea of having a peer group to review AI-built drivers—feedback and insights would be invaluable.

It’s exciting to see more non-coders empowered by AI in our community, and your approach shows just how far we can push the platform. Kudos again, and here’s to more creative AI-driver adventures! :rocket:

6 Likes

Thank you for this! It's confirmation knowing you considered "setting up a GitHub repository" but hesitated because of concerns for "unintended consequences releasing it". This is exactly the issue I was hoping to address in this post.

Here's what I know... AI helped me resolve an issue - it's working. It may be the last Hubitat driver I ever create. Thus, I have no interest in setting up a GitHub and dealing with potential hassles as a result.

I don't think I'm alone on this, and can't help but wonder what other solutions might exist that will never benefit the community as a result. I find that unfortunate, especially because I believe AI is making this situation more-and-more prevalent. Personally, I'd like to see an easy path for non-coders like us to submit our AI works through a structured review process.

Cheers!

1 Like

How do you envision this working?

There is no structured review process for human developers in the Hubitat community that create apps and drivers.

2 Likes

Good question. Not sure. Perhaps allow community members to share their AI generated code here?

Funny thing .,. I have made a few apps and drivers for hubitat using AI
And got a bunch of crap for doing so and now they stole my idea and have it built in to the hub! lol
I have to agree you need to test and say the correct things for the AI to understand and make what you envision the app or driver you want it to do.
But amazing enough a lot of times it works ok very well.
It would be nice to have a place to " share " your AI apps and drivers.
But really there already is .. Custom Apps and Drivers category

Please no. Non coders that prompt and hope for the best is the worst possible thing anyone can promote... At this time. The quality is quickly evolving so there will be a day where things are better.

If by structured review process you mean other people have to sift through Ai generated code that was generated using prompts from a non software engineer looking for architectural and other problems ? Like 90% of the work?

Do we mean to enable the non engineer idea person to have a fast path using a prompt and abandon approach to the software they are developing using Ai?

If you want that how about a forum here for Ai prompts? You get a gold star for your prompt and we use those prompts across the dozens of existing models and all future models. You can be known for your clever idea and prompt.

Lots of inside baseball in the above.

What hassles could result? I'm genuinely curious what you mean. But GitHub is just one place you could host your code. No matter how you do it, you need somewhere to do it. If you do not like GitHub, as I mentioned, there are alternatives, or really any site capable of hosting plain text or files would work. You could even link to a Dropbox or Google Drive shared file, though that is less common likely because they are not geared towards code sharing specifically and don't work well if collaborating (branches, version control, etc.). Hubitat does not offer anything themselves, and I would not count on that changing any time soon; both this and some review/rating/etc. kind of thing have been discussed many times in the past.

Interestingly, there is nothing stopping anyone from starting something like this on their own if they want, but to date, no one has. HPM is somewhat in this vein but has none of the above (actual hosting -- you still need to do it somewhere -- or any kind of review, other than that I suppose an admin could remove a problematic repo in an extreme case).

But setting up a repo (or any solution) to host a file yourself shouldn't have any more consequences than any other thing you probably already do online.

In case this isn't at least partially in jest, what the hub is doing is different: it's not writing an app, and the output is not from an arbitrary model. It is creating settings (the same ones you could make in the UI yourself) using a model staff engineers have trained to produce such output that can work inside the framework of the existing Visual Rule Builder app. The result is the same as any Visual Rule Builder rule you could have created manually.

1 Like

That’s pretty much how it works already, whether the code is human or AI developed.

That’s not an accurate summary of what happened. You created a few threads with step-by-step instructions created by ChatGPT (and at least one of those sets of instructions contained errors), and also code created in collaboration with ChatGPT.

But it was not clear to others what content was yours, what was ChatGPT’s, whether you supervised/revised anything ChatGPT created, etc.

That’s all I would ask of anyone who uses generative AI to create text for a forum post or driver/app code: be explicit about what was created by AI and what role, if any, a human played in supervising its output.

LOL yes I was jesting hence the LOL at the end :slight_smile:

Yeap .. But so is a small app you make yourself or a AI that does the same thing.
Some people, including my self find real hard to make and figure out how to use Rule Machine or Visual Rule Builder < but to have a AI make it for you well that is and seems easier .. hence why they added it to the hub i would think ?
And really there very little difference between a APP and a RULE on what it can do.