Detecting if the current ecosystem is a SmartThings or Hubitat setup

I was trying to have my code detect whether it is being run on a SmartThings or Hubitat Setup.

By default, Hubitat doesn’t seem to have any API call which provides something similar. But the below function seems to work well for me.
Hope this helps someone else who may be looking for a similar requirement.

def getEcosystem() {
    String hubdomain = location.getHubs().find{ it.getType().toString() == 'PHYSICAL' }
    if (hubdomain.matches("com.hubitat(.*)")) {
        return "HE"
    }
    else if (hubdomain.matches("Smartthings(.*)")) {
        return "ST"
    }
}
1 Like

heres what i have been using … from discussion on another thread:

def getHubType()        {
    if (!state.hubId)   state.hubId = location.hubs[0].id.toString()
    if (state.hubId.length() > 5)   return _SmartThings;
    else                            return _Hubitat;
}

might actually change it to use hubdomain.

thanks.

1 Like

Or maybe:

def isHE = location.hubs[0].id.isInteger()
2 Likes