[RELEASE] SensorPush Gateway Driver

That's good to hear, hopefully it is just something in my setup.

How do you make a Dashboard that looks like this? All I can get is little squares.

It looks like @par.botes used HubiGraphs, which was a Community developed app, but the developer no longer maintains it. I'm not sure if you can still install it or not, I only tried it out some time ago, but haven't used it really myself.

Aside from the tiles that can display single values, there's no real built-in charting option, hence the reason for Hubigraphs... Other options include sending readings to an external database and using charting tools outside of the HE hub. In my case I send data to InfluxDB and then use Grafana to produce charts, both InfluxDB and Grafana run on a raspberry pi in my case. I use this not only for temperature and humidity charts, but also details from my smart plugs that have energy monitoring and data captured about the state of my HE hubs, such as memory usage, CPU, etc.

I use the free version of Adafruit IO to record data with my current home automation stuff. Using a PI to read various sensors, then post the data to the cloud.

As I have recently moved to Hubitat I've got some new learning to do. I'm a long time home automation geek and recently retired MS stack developer. I'm shocked at the lack of direction\docs for developers getting started with Hubitat.

Your solution intrigues me, how are you sending data to InfluxDB? My approach was going to have the PI use the Maker API to get data from Hubitat. Any links/info to help me learn about your process would be greatly appreciated.

This is the one I landed on for getting data to InfluxDB:

You may also get some useful information from here:

Here are some notes on how I got Grafana charts on my dashboards. Nowadays you don't necessarily need to use the Tile Master driver to achieve the HE dashboard part, you can use any iFrame driver such as the iFrameAdvanced driver here on the Community.

Thanks for all the info. I'm still a Linux noob but am working on that also now that I am retired.

1 Like

Yeah, I was somewhere in between, I used Linux a reasonable amount with my first job, but not every day, just to move files around and use the ERP system the company developed. So I was certainly more comfortable in a Windows environment, but had been interested in purchasing a pi for some time. One advantage, I think, particularly for things like this, is so many other people have used things like a rpi or a NAS to set these up, most of the instructions and questions posted on forums work through peoples setup on these systems, so you have a healthy supply of resources to draw on if you get stuck or in setting them up to begin with.

I have recently installed this app, and it's working great, but I'm noticing a couple of errors in my logs regularly:

dev:230 2022-06-15 18:22:00.644 errorjava.lang.IllegalArgumentException: No json  exists for response on line 262 (method getAccessTokenCallback)
dev:230 2022-06-15 18:22:00.302 errorjava.lang.IllegalArgumentException: No json  exists for response on line 154 (method samplesCallback)

I'm getting this message every time that is polls the sensors. Is there something that I don't have configured properly? It seems that it is pulling the data properly.

Another thing I'm trying to figure out, is there a way to set a condition to trigger if a sensor hasn't updated in a while, like a low battery or loss of communication. I haven't looked into the API yet to see if there is something that could return a value.

I've been meaning to post about that error. I have been getting it for a while myself. I suspect SensorPush may have changed the timeout on the auth token, but have not confirmed this.

To get around this I (and I would suggest you do the same for the time being) setup a rule in RM to periodically run the getAuthToken command on the gateway device, I think it was every 6 hours. You can do this using the run custom command action.

What I should do is build this regular update into the driver and handle the error you are seeing more gracefully, including initiating an attempt to retrieve the auth token.

I'd like to do this as well, but not sure when I will get to it. You are welcome to take a look and play around with the code, I'm happy to include changes by other developers.

Simon

Simon,

Made some small updates to the SensorPush driver, adding units of measure and description text to the events, as well as description text info logging if enabled. I created a pull request if you're interested in folding in the changes.

Thanks for the driver!

1 Like

Thanks, I'll take a look, but can't think of any reason not to include those changes from what you've described. I'd like to make a few of my own, I might include a couple as well.

1 Like

Version 1.0.4 released - Added description text and units to temp and humidity events, Added info logs

Thanks again @coreystup

1 Like

Thanks so much for creating this! Just received my Gateway and got this app up and running in minutes - bravo!

1 Like

Things have been relatively stable with this driver, so I have not needed to make many changes, hence it's been quiet here on the topic. At the moment I am looking to make some relatively minor changes to the driver:

  • Only record device events when there is a change in temperature or humidity readings, rather than the current behavior of an event being recorded each time readings are polled. This should reduce noise and improve accuracy of triggering based on these events.
  • Similarly, make sure the device "Last Activity" is only updated when there is a change in the reading, improving any monitoring people may want to do for device activity as an indicator for battery health, etc
  • On the Gateway parent device, move the access token and authorisation code values to state variables, rather than attributes, avoiding any unnecessary issues with attribute lengths or visibility of these values

I will also include some extra debug logging, and automatic timeout for the debug logging preference setting and other general code improvements.

Let me know if anyone has any concerns about these changes.

1 Like

Personally, I prefer to let the Hubitat Platform perform the de-duplicating of events for me. This ensures that the driver logic is not trying to duplicate what the platform is already doing on your behalf.

As long as your sendEvent() call does NOT include "isStateChange: true", the platform will handle deduplicating all events. Only a changed value will cause the platform to generate an actual Event that Apps are subscibed to.

As for the "Last Activity", again I would let the platform handle it. IMHO, if a device is transmitting the same value periodically, the Last Activity should still change to let the user know the data is flowing. This assumes that the duplicate data values are truly current readings, and not stale.

However, if your driver is communicating via polling, and the device/gateway on the other end is caching and sending old stale data, then I can see your point. It would make sense to implement both of your first two changes to ensure the sensor really is working correctly.

I have a bunch of Zigbee sensors that do periodically send duplicate data, like battery levels. This causes the Last Activity field to update, but no new events are generated. This allows me to use a Device Activity monitoring app to alert me if the device's battery dies without reporting a low battery level for some reason.

2 Likes

This was the problem with the Events, I was including the isStateChange: true. I initially wrote this relatively early on in my time writing code for HE, so either did not realise what is meant or the impact on triggers, monitoring, etc with logging redundant events. So part of the changes will be to remove this isStateChange from the map for the sendEvent call, but unfortunately that was not the whole story....

Yeah, initially I thought I was starting on a relatively small and simple change to comment out one line for each event (temperature and humidity).... I saw the Events reduce, but the last activity still updating. I eventually worked out (partially through a another topic you were part of) that the calling of the sendEvent, even with the stale readings was producing the updated last activity. And yes, I am polling the cloud service that sensors (via the gateway) send the readings to, so I unfortunately need to check the current values and compare, rather than relying on the device sending only state change messages directly to the hub.

This was my target as well.... Wanting to setup some monitoring for no new readings coming through, indicating something is wrong, acknowledging it may not always be a battery issue in my case.

1 Like

@sburke781 Hey, long time no chat. Have you seen anything weird happen with this driver lately? It's been running solid for the last three years but recently started throwing errors and not updating.

[dev:111]2024-10-02 12:59:30.483 PM[error]samples: Exception groovyx.net.http.HttpResponseException: status code: 400, reason phrase: Bad Request

[dev:111]2024-10-02 12:59:30.330 PM[error]getAccessToken: Unable to query sensorpush cloud: groovyx.net.http.HttpResponseException: status code: 412, reason phrase: Precondition Failed

I've reached out to SensorPush and they say nothings changed on their side and I know the code here hasn't changed so I'm perplexed. I still have a C-7 and it's up to date on the running version.

Any insight is appreciated!

G'day Brian,

I haven't seen a 412 error recently, that is strange. I periodically see a fairly benign error with invalid JSON for samplescallback, but that is more just something I need to handle in the driver rather than an error.

Are you on the most recent version of the driver?

Without looking into it too deeply before work, I would suggest trying to reset to security token on the gateway device. I would need to check the code to try and remember if it's the initialize or refresh command that does this. Alternatively, rebooting the hub could potentially resolve a few other possible issues, but it is a bit of a blunt instrument.

Regardless of whether you do either of those, turning on debug logging and sending me a PM with the output may yield something.

It is likely a couple of days before I can really take a good look at it, but can usually spare some time here and there if you have any new info or questions.

Simon

No worries. It's been acting up for a while so another couple of days isn't going to matter. :wink:

1 Like

@Dread_Pirate_Roberts ,

On the gateway device in HE, try running the getAuthToken command and see if that resolves your issue.