Using openAI's chatbot to create rules for openHAB

I just had the idea to ask openAI’s chatbot to create an openHAB rule for me. And the result I got is pretty stunning:

Surprisingly it even provides more complex rules, or at least the basic idea of how it might work:

While it helps proving the basic idea for how a specific goal can be achieved, it sometimes provides wrong results that manually need to be corrected (either by doing it on your own or asking the bot to use a different approach)

I am not entirely sure if this is helpful or confusing as the results are sometimes not valid rules, especially once it become more complex.It might help to get a starting point though if you are completely lost.


I must say, this is completely insane.
This chat-gpt is truly astonishing.

Anyway, thanks for sharing this idea, this is very interesting.
(Now I want to play with it…)

1 Like

wow it works pretty well for getting a start

wtf i just asked him to do a simple alarm system this is not my coding

rule "Alarm system with pincode and motion sensor notifications"
    Item MotionSensorGroup changed
    // Check if the alarm is already armed
    if (AlarmStatus.state == ARMED) {
        // Check which motion sensor triggered the alarm
        var String sensorName = MotionSensorGroup.members.findFirstMatch(member|member.state == ON).name

        // Prompt the user for a pincode
        var String enteredPincode = prompt("Enter pincode:")

        // Check if the entered pincode is correct
        if (enteredPincode == CorrectPincode.state as String) {
            // Pincode is correct, disarm the alarm

            // Play a disarm sound

            // Send a notification to the homeowner
            sendNotification("Alarm disarmed. Motion detected in " + sensorName)
        } else {
            // Pincode is incorrect, play a loud siren sound

            // Send a notification to the homeowner
            sendNotification("Incorrect pincode entered! Intruder detected in " + sensorName + " Check the security camera for more information.")

            // Turn on all the lights in the house
            sendCommand(AllLights, ON)

I don’t think “prompt” is a valid command though… Also most likely the Lux-Sensor example should be “inverted” as it’s decreasing the brightness with decreasing ambient lighting, so you should have asked it to correct that :wink:

1 Like

i am impressed. look when you dont know where to start its a good kick.
Well for the lux i would send first 100 and then decrease it and if else off but still pretty good example also the alarm looks like a good start.

I also discover that Chat GPT can create openhab DSL rules and give a very good starting rule.
Same for Arduino’s board code…

This impressed me much