Getting Ubi Sensor Data the Hard Way... Or how I stopped worrying and learned to love the XMLslurper

Yeah, this ain’t pretty, but it is a proof of concept on how to get a web page data and parse it.

Someone might want to refine this a bit, but I wanted to get it out there, and see if we can force the Ubi guys to make a much more official way to get this data.

Anyway, its ugly, its not going to work for everyone, could break at any time… But it is proof that you can grab almost any data off a website and use it for a devicetype…


Excellent, I thought about parsing the info from their site as well. I was hoping that they would expose the information and allow us to pull it in without doing this. Like you have stated, let’s hope that this gets them moving in that direction.

Also why I didn’t refine this. This is a HACK of the roughest sort. BUT, it works. For me at least.

This also opens up potentials for stupid IoT devices that don’t have a proper api but at least display the data on a page.

The only thing I have to say, is it shouldn’t have been this hard. Probably isn’t but this is how I finally got it working…

Why regex.matcher isn’t allowed is beyond me…

Now off to hack my sleepnumber bed with sleepIQ so smartthings knows when I’m asleep and when I wake up…

@pstuart There is a regex syntax that is allowed and may clean up what you were wanting to do.

def info = (commandData.params =~ /vendor=(.*)&model=(.*)/)
if ((info[0][1] != null) && (info[0][2] != null)) {
    log.trace "vendor = " + info[0][1]
    log.trace "model = " + info[0][2]


Nice work! Thanks for doing this.

Am I correct in assuming this is a Device Type? After adding it as a device type and publishing it, how do I add it to my things?

Not sure what you mean. Yes it is a devicetype, it creates a device that has the sensors from the Ubi.

Temp, humidity, luminance, Air Pressure and Sound Level.

These can then be accessed and updated on Poll()

This device will create tiles to display the data from the Ubi.

Your things are already on ST…

I must be missing something here. I added this as a device type in the IDE. No issues there. Now how do I access this device? Does just adding the devicetype automatically create a device in SmartThings?

This is beautiful. Thanks @pstuart!

No you then need to create a device and select this devicetype either in the ide devices or in the app.

Will this refresh regularly or only on demand update when I refresh app tile ?

It will not update regularly, devices have no built in access to schedules. Smartapps can do this. There is a Polling app

That can be used to get this data updated on a regular basis.

This is sweet. Nice hack job!

Some minor updates to allow sensor data to be logged via my Xively logger.

How do I use this if I have more than one UBI device?

You don’t. Official API calls now support getting all sensor data in json.

Just waiting on Ubi to allow everyone the ability to access the api

What do you use for the device_id @pstuart, I am getting java.lang.NullPointerException: Cannot invoke method writeTo() on null object @ line 137

DeviceID isn’t used, so you can set it to anything unique.

Code’s working for me, is it possible your username and password are wrong? Also, how many ubi’s do you have? If you have more than one, it might be the issue.

Must have had a typo in there somewhere. I double checked all the settings and it is working. Do you have API access for the UBI yet? I have requested it, but have not heard anything back from them.

Yes, I have it, waiting to release code until others will have it. PM me an email address, and I can set you up with the API code and see if it will work using my API access.