Yup - except my location name is "ChezBurke". Where is the Hub Name?
(Platform version is 2.0.7.126)
hub name and location name are are separate fields in the schema...
location name is shown everywhere and can be modified, the hub name cannot be updated. we have an issue open to fix this.
As they should be. But where can I change the Hub name?
Importantly, it is NOT being set to the MAC address of the hub, so the recommended code above to detect the hub type (counting ':'s) doesn't work...
Yes, there is a comment from me above not to rely on this field.
Awesome.
So for now, I'm using the following code to test for Hubitat vs. SmartThings:
private getHubPlatform() {
def p = "SmartThings"
try { def foo = physicalgraph.device.HubAction.newInstance() } catch (e) { p = "Hubitat" }
return p
}
(Edited to correct case of HubAction)
The fix is to set the hub name equal to the location name, so that code that @srwhite references should not be used going forward.
private getHubPlatform() {
def p = "SmartThings"
try { def foo = physicalgraph.device.hubAction.newInstance() } catch (e) { p = "Hubitat" }
return p
}
But why when this works:
if(!physicalgraph) {
log.debug "Not a SmartThings hub"
}
else {
log.debug "It's a SmartThings hub"
}
Groovy has built-in object null checking. Try/catch should never be used as an if block. Too much overhead.
OK - it's your software.
But I would suggest that you use a different name for the Hub vs. the Location - even if the hub name is set to " Hub", as it is on SmartThings. The fewer differences between the two platforms, the better (IMHO).
DOH!
That is indeed more efficient - THANKS!!!
Anytime sir!
And here I was having a good day, that'll teach me to come on the forum and help out!
On ST the hub name is set to location.name + " Hub" I'm assuming that is what you mean?
Yes, sorry...I inadvertently put "location" inside less-than/greater-than symbols.
And I meant no offense...sorry, I'm new here and TRYING to tread lightly...
Actually, your code doesn't seem to work - if (!physicalgraph)
is TRUE on SmartThings as well (apparently `if (physicalgraph) is false on both platforms).
Good Lord you guys are getting sensitive/touchy on comments/suggestions...
Toughen up, buttercup. Bruce says way worse stuff than that at least once a week. Lol.
Maybe we all need to just hug it out.
Edit: to be clear those last two parts were ment as sarcasm / a joke. I know that isn't always obvious in the written word.
Crap. Ok. What about if(!physicalgraph.device.hubaction)?
I would expect that one to work. But I'm not in front of my hubs.
Who are "you guys"? its just me here. But yeah, I'm heading out. gotta toughen up.
Don't mind me. I've been around rugby fans all week in Wales. They're all jacked up on a adrenaline right now. Lol