[RELEASE] SensorPush Gateway Driver

SensorPush Gateway Driver

This driver connects to the SensorPush cloud-based API to retrieve sensor readings.

Background

SensorPush sell a temperature and humidity sensor with Bluetooth connectivity for connecting directly to a mobile phone / tablet to collect sensor readings. Each sensor is able to store up to 20 days worth of readings that can be downloaded when the mobile device is back in range. You can also purchase a gateway to allow readings to be sent to the SensorPush cloud storage, making these available away from home on your mobile phone and through the SensorPush API.

NOTE - This driver relies on the use of the SensorPush Gateway and the storage of sensor readings in the cloud, it cannot connect to SensorPush sensors directly.

The Driver

How Does It Work?

The SensorPush Gateway driver connects to the SensorPush cloud-hosted API to retrieve the list of sensors configured on the gateway, setting up two child devices per sensor, one as a temperature sensor virtual device and another as a humidity sensor virtual device. Regular updates of the current sensor readings can be configured, either using the in-built polling options, or using an RM Rule to trigger a device refresh for the gateway device.

Installation and Setup

The driver code is located here

Installation still requires the standard / manual method as I haven't set this up in Package Manager yet.

Installing the SensorPush Gateway Driver

  • Access the driver from the GitHub link above, clicking on the RAW button to open the text only view
  • Copy the driver text from the RAW view
  • On your HE hub, open the Drivers Code section of the HE Web UI
  • Paste in the driver code
  • Click Save to install the SensorPush Gateway driver

Before starting to call the SensorPush API you MUST access the web-based SensorPush Dashboard to accept their terms and conditions. Log into the dashboard with the same credentials used to setup the Gateway in the SensorPush app. Thanks to @Dread_Pirate_Roberts for reminding me of this.

Creating a SensorPush Gateway Virtual Device

  • Open the Devices section of the HE Web UI
  • Click the "Add Virtual Device" button on the top right of the page
  • Enter a "Device Name" and select the SensorPush Gateway driver from the "Type" drop-down list
  • Click the "Save Device" button to create the new device
  • The Device Edit page will display

Configuring the SensorPush Gateway Virtual Device

  • In the Preferences section, enter your Username / E-Mail and Password used when setting up the Gateway with SensorPush
  • Choose whether to enable or disable the Automatic Sensor Polling option, and if enabled, the number of minutes between polling of sensor readings
  • Adjust the various logging options to turn on and off the different levels of logging that can occur, e.g. Information, Error, Warning and Debug Logging. It is recommended to leave Error Logging enabled.
  • Click "Save Preferences"
  • Click the "Get Auth Token" button (command) at the top of the device edit page, this will authenticate with the SensorPush cloud-hosted system
  • Click the "Refresh" button (command) for the device
  • Refresh the browser
  • Review the Device Details section at the bottom of the Device Edit page. Ensure the 2 Component Devices have been created for each sensor, one for Temperature, one for Humidity. If the Automatic Sensor Polling option is turned on, ensure the Schedule Job details are displayed.
Using the SensorPush Gateway / Sensor Devices

The child devices for each sensor can be used in a number of different ways, including displaying temperature and humidity readings on dashboards, in RM rules, in various community apps, as well exporting to external data logging and visualisation setups.

Change Log

2021-02-27 - Temperature Conversion

  • Updated samples method, replacing code to always convert to degrees C with a call to convertTemperatureIfNeeded to convert temperature readings based on HE hub temperature scale setting, including before and after debug logging for the temperature conversion
  • Minor adjustments to some logging to include correct method references
  • Adjusted notes on HE Community thread to include step to accept terms and conditions on SensorPush Dashboard web page - thanks @Dread_Pirate_Roberts

2021-04-17 - Automatic Polling Fix

  • Corrected issue with the automatic polling, it now honours the interval minutes setting correctly

2021-05-16 - Automatic Polling Fix

  • Corrected the CRON job setup again, somehow it was still wrong...

Enjoy!!

Simon

3 Likes

Works great, thanks for updating this!

A couple of things for anyone that isn't super familiar with the SensorPush API:
Go here to see the base URL: sensorpush DOT com/gateway-cloud-api
Currently it's api.sensorpush DOT com/api/v1 although I suspect that will change over time.

If you have not logged into the API dashboard before YOU MUST do that at least once to accept the terms or else you will never get authorized. And no, using their phone app doesn't do that for you. You much log into the dashboard. The dashboard URL is here: dashboard.sensorpush DOT com

Thanks again Simon, super excited to start making this part of my integrations.

1 Like

No worries, thanks for adding the info to this thread. I think I have made some tweaks since the release, I'll take a look today and update the code in Git.

Simon

1 Like

Oh and I just figured out this is hard coded for celsius. I know, we should get into the modern age around here, but that just ain't happening! :rofl:
Took out the calc conversion on line 133 and it's good to go for us yanks.

1 Like

Thanks, I'll do the same and update the master copy of the driver.

Also, am I right in remembering you have to contact Sensorpush support to arrange access to the API?

I did not. I have had the wifi bridge for several years and have been using the app so I had a log in for that and that worked in the API dashboard too. That was the critical step to allow access because you have to accept the terms and conditions for it to validate your log in.

1 Like

@Dread_Pirate_Roberts - Any chance you could test changing that line to:

def temperature = convertTemperatureIfNeeded(tempStr.toFloat(),"F",1) 

I've posted a question on exactly how this method is meant to work because I got some weird behaviour. Would be interested to know what you see on what I assume is a hub with a temp scale of F.

Thanks,
Simon

Stand by trying that now.......

1 Like

Looks like I get valid data, but the log throws this:
[error](xxxxxx device/edit/111)samplestest: Exception java.util.IllegalFormatConversionException: f != java.lang.String

I go back to
def temperature = (Double.parseDouble(tempStr))
and no error.

1 Like

Ok, that's fine, I sorted that out error myself with the changes I have made in the driver, but just gave you that one line, forgot about the other fix further down in the code. I'll commit the changes I made to the Git repository and perhaps, if you have some time, you can test the full update to the driver.

Thanks again for your help with this.

Simon

I've included a Change Log section in the first post, including my first change to include a temperature conversion that detects the temperature scale on your hub and converts the reading if required. Please update the driver code from the Git repository link in the first post.

Simon

No worries, more than happy to give it a go! Let me know when it's posted and I post back here what I see. I'm new to this community, but I already can tell I'm going to like it around here.

-Brian

1 Like

You're good to go, I've updated the driver in Git, so if you follow the link from the first post you should get the updated code. Thanks.

1 Like

Looks good! Everything update correctly and no log errors that I've seen after several refreshes.

1 Like

Excellent, thanks for testing it out.

1 Like

Thanks for writing it!

Wonderful! works really well!!!

Quick question (and possibly a dumb one). I figure i would like to poll sensorpush hourly for the humidity data. I configured my settings like this:

I saw your comment about checking for scheduled jobs but i can't see any jobs being scheduled. am i doing something wrong?

Did you hit Save Preferences?

Either that or try refreshing your browser window

I did hit save and refresh. reloaded my browser window too.
Just tried it again, no change in the window, eg. i don't see a "next scheduled job".
Maybe i shold set it to a minute and debug it manually for a bit to see what i get in the log.

Download the Hubitat app