Learn to code for Hubitat

I was hoping to see some folks in the IRC channel but no one is there. Are any of the devs here willing to teach coding? I have always wanted to learn but the tutorials and coding videos are not specific and assume you have some knowledge already. If any of you would be so kind to want to teach please PM me. I would like to allocate at least an hour a day.

TIA RH

3 Likes

Would love this too and one of the members @adamkempenich has started this with a YouTube video. Take a look it's worth a watch.

6 Likes

By coding, I assume you mean writing your own apps and drivers in Groovy. I see that @BorrisTheCat beat me to posting a link to a long live video that @adamkempenich did about a month ago.

You might find that to be a useful start.

The Groovy language itself is documented here:
http://www.groovy-lang.org/documentation.html

There's a reasonable amount of Hubitat Developer documentation available here:
https://docs.hubitat.com/index.php?title=Developer_Documentation

Finally, for the small amount of Groovy app development I've done, I found the SmartThings Classic Developer documentation to be invaluable:
http://docs.smartthings.com/en/latest/
(corrected link - thanks @ogiewon)

11 Likes

There's an IRC channel?!

4 Likes

@MrCaspan started one.

5 Likes

I don't remember the last time I was on IRC and I started my programming career building IRC server software!

3 Likes

IRC is so old skool. :smiley:

5 Likes

@aaiyar I have been reading and have watched Adam's video as well. I guess I would just like a scenario where we can all work on a project where we set our IDE up the way the leader takes us for the lesson. For me, I can read until my eyes bleed. But there are so many questions.
Maybe even a MS Team's setup where we can get a few of us who are interested and have one of you guys walk us through basics.

1 Like

That's a SmartThings thing... Hubitat does not have it as a separate service.

Coding is all done via the left menu under the respective Apps Code or Drivers Code

2 Likes

@Evilborg I was talking about itellij idea, visualstudio, notepad++, etc.

I don't use any of those. I code everything via the hubitat UI and test on my dev hub

3 Likes

Understood, I have been reading and thought ItelliJ IDEA had some autocorrect mechanisms built in for groovy.

I use linux here and the app I use is Kate which does groovy formatting

2 Likes

I have that set up with the groovy plugin. I am trying to use the public driver/app examples but not sure where to start.

Ok here is what I have so far. I am trying to work from the code Adam shared in his video.
I am simply trying to turn on/off an inovelli lzw42 directly. What else do I need to make that happen? I know I am missing something, probably a bunch...

/ ** A Dimmer **/ 

metadata{
    definition(
        name: "Dimmer type",
        namespace: "development",
        author: "Adam Kempenich",
        importURL: "") {
        
        capability "Actuator"
        capability "Initialize"
        capability "Switch"
        capability "SwitchLevel"
        command "toggle"
    }
}

def initialize(){
    log.debug "Device initialized."
    
    // Do nothing, since nothing needs to be intialized
}

def updated(){
    log.debug "Device update"
    
    initialize()   
}

def on(){
    log.debug "Device was turned on"
    
    sendEvent(name: "switch", value: "on")
}

def off(){
    log.debug "Device was turned off"
    
    sendEvent(name: "switch", value: "off")
    
}

def setLevel(level, duration) {
    
    sendEvent(name: "level", value: level.toInteger())
    sendEvent(name: "duration", value: duration.toInteger())
}
def toggle(){
    log.debug "Toggle Called"
    
    if(device.currentValue("switch") == "on") {
        off()
    } else {
        on()
    }

}
1 Like

Not sure what your ultimate goal is but that won’t work. You’d need to implement zwave commands to communicate with the device.

2 Likes

@dman2306, for the moment all I want to do is learn to code the bulb to turn on/off. I am trying to learn to code.

1 Like

your ahead of me :wink: I got about 1 hr in. Following, and trying to learning too :+1:

1 Like

Gotcha. To do that for such a device you’d need to send a zwave command for on and off so the device knows what to do. The sendCommand will just update the on/off status in HE but it won’t send anything to the actual device.

2 Likes

@dman2306, can you point me to where there may be some examples of this?
Also, I assume this information will be necessary to use the z-wave commands? Or no?

fingerprint  mfr:"031E", prod:"0005", deviceId:"0001", inClusters:"0x5E,0x85,0x59,0x86,0x72,0x5A,0x33,0x26,0x70,0x27,0x98,0x73,0x7A", deviceJoinName: "Inovelli Bulb Multi-Color"