How to get local IP of the Hub?

I am working on an App that will hopefully use a local OAUTH endpoint. Per the following post, I need to be able to get the hub’s local IP address.

https://community.hubitat.com/t/how-to-get-cloud-endpoint/266/2?u=ogiewon&source_topic_id=418

As such, it will need to display the url of that endpoint to the user to be included in the configuration for a raspberry pi based application.

I have tried the folllowing snippet of code which works for all but the last 3 fields. Is there another call to get the “localIP” of the hub?

def hub = location.hubs[0]
log.debug "id: ${hub.id}"
log.debug "zigbeeId: ${hub.zigbeeId}"
log.debug "zigbeeEui: ${hub.zigbeeEui}"
log.debug "type: ${hub.type}"
log.debug "name: ${hub.name}"

// these 3 all throw errors on Hubitat
log.debug "firmwareVersionString: ${hub.firmwareVersionString}"
log.debug "localIP: ${hub.localIP}"
log.debug "localSrvPortTCP: ${hub.localSrvPortTCP}"
1 Like

Hubitat support provided the solution in a private message, so I thought I should share it here to help others.

	def hub = location.hubs[0]
	log.debug "id: ${hub.id}"
	log.debug "zigbeeId: ${hub.zigbeeId}"
	log.debug "zigbeeEui: ${hub.zigbeeEui}"
	log.debug "type: ${hub.type}"
	log.debug "name: ${hub.name}"
    //note change to these two calls for IP and Port information
	log.debug "localIP: ${hub.getDataValue("localIP")}"
	log.debug "localSrvPortTCP: ${hub.getDataValue("localSrvPortTCP")}"

FYI, hub.firmwareVersionString was added to release 1.1.2

1 Like