Official API

@MarkDodrill ,
Here’s the informal Sense API.. It might do what you need though your request for data aggregated over several seconds is a big ask - I think the API is based on half second intervals.

1 Like

Is there a way to get the Sense data that’s sent over the Internet, directly from the Sense device? I’d love to be able to write a program to monitor what’s happening in real-time and be able to turn devices on and off myself based on what’s happening in real time.
It would be much more efficient to get this data directly from the Sense device, rather than going out to the Internet to get it.

Are there any plans to make this possible?

Mark

2 Likes

Not today. I think any API that would talk directly to the Sense monitor would have the potential to overwhelm the existing CPU resources of the already heavily burdened monitor. Of course, if your are really ingenious and persistent, you could try to decipher a mirrored stream of packets going to the Sense mothership.

The informal Sense API does let you sample Sense data from the mothership/cloud and you could certainly build your software to work with that. Or you could look into Home Assistant which already has a nice Sense integration for data collection and can be used with something like Code Red control, to switch smart devices in your house on and off.

I also would love at least lighttpd or nginx locally and just be able to scrape the numbers for generation/consumption off it incase of cloud outage or other major issue with sense to make it at least a energy monitor and can still get data off of it. A local API even better, but i could understand with the hardware limits why that may not work.

Thanks for merging this with existing threads, sorry I missed it.
Will look at the unofficial Python API to get what I want – it looks like just what I was wanting!

Thank you.
Mark

6 posts were split to a new topic: Python Script for Sense + Weather Data Tool

Did sense kill off the API? i can no longer connect?

mine is still working, it just did it 15 seconds ago, no issues

Ok thanks… suddenly started working that night. maybe i was just blocked for some reason… but had stopped for a little over a day.

It’s been four years since Sense acknowledged the need for an API, and it seems there’s still no proper API?

@rmann, maybe I’m naive, but I have used the Sense informal API a few times and find it useful and relatively easy to use, though limited to just a snapshot of the power and voltage data at any one moment in time. What would you do differently if there was a “proper” API for this data ?

For one, I’d document it :wink:

I’ve found a couple of SDKs for it on Github, but nothing that really shows the endpoints’ usage (I’m not coding up something that can use the existing Python SDKs). I can pore over them to figure it out, of course, but I haven’t done that yet.

And by “proper” API, I mean I’d like to query the Sense device directly, locally, to at least get the total power stats.

I can see there’s a websocket connection to the server to get the rapidly-updating info, and hopefully I can connect to that, but I haven’t tried yet and am not sure what authentication it might use (it’s much less standardized with websockets). I also don’t know if it uses Phoenix or some other messaging layer on top.

Lastly, I had to turn off 2FA to be able to authenticate with the one API I did try; dunno if someone has figured out how to include the 2FA token. A “proper” API would have a client key to help facilitate that sort of thing (i.e. 2FA is more useful for preventing malicious modification of an account, and perhaps less critical for read-only APIs).

Thanks for the specifics.

  • This is the GitHub project I’ve used for a few interesting experiments with Python.
    GitHub - scottbonline/sense: Sense Energy Monitor API

  • Agree with you on documentation, though I found the example to make usage pretty self-explanatory, including authentication.

  • I’m just another user, but I find the requirement to talk to the Sense monitor directly puts your request in another universe entirely, given the cloud-connected nature of the Sense product. There are probably better devices, like the Rainforest Automation Eagle 200, to use if you want a local API.

  • I agree on the 2FA, though I have found that 2FA on some of my home IoT devices screwed up various integrations versus simple password-based authentication. I haven’t moved my Ecobees to 2FA because there are other home integrations that still can’t handle 2FA.

What are you trying to build ?

1 Like

I only just discovered the Python and the Sense API a couple of months ago, and I already have that TesSense app written that I use to control my Tesla’s charging, so it only charges on sunshine.

I have learned about all sorts of other APIs besides just the Sense and the Tesla ones. There’s one for Sunrise/set, one turns coords into addresses, and the most important one is the TPLink API that has allowed me to contact each of the SmartPlugs that the Sense is talking to and control them directly. I now have it set up so when the Hot Tub kicks in all the space heaters in the place turn off, keeps me using as little power from the grid as possible.

That last one was a bitch, had to learn how to program for multitasking to use any functions, and I got a lot of help from the SenseLink guy Charles P., he did the initial pass at getting my code to show the Tesla charging on the Sense monitor. Thx again Charles, and Tim and Scott…

2 Likes

The Unofficial API library at GitHub - scottbonline/sense: Sense Energy Monitor API includes support for 2FA. It will return SenseMFARequiredException on login if 2FA is enabled and then the code can be sent with the validate_mfa() function

Still would love a local API of course.

1 Like

What do you suppose we can get from a local API? I assume it’s a dumb device that just sends compressed data to the Sense Host

1 Like

Local API that provided current power usage (voltage, watts on each leg) would be handy. I wouldn’t expect any device info, but live totals can still be good to have and would reduce the need to ping the cloud as often.

2 Likes

Sorry, I missed this question before. I’m trying to integrate things into my smart home, which is completely bespoke. Today I’m trying to make little indicators that show how much my electricity is costing me at this instant (time of use rate X current consumption).

And more importantly, I’m trying to do this in a way that doesn’t depend on a cloud provider. Internet access is unreliable.

Thanks - As a fellow user, I don’t think you are ever going to see a local API to the Sense monitor for a couple of reasons.

  • CPU bandwidth - given all the Sense monitor is already doing, and the unpredictability of what end-users might request via a local API, there are real risks of overloading the monitor. It’s already doing an amazing amount of collecting, processing and compressing/packaging data for delivery back to the mothership. I’m guessing that there are are number of realtime deadlines that must be met, and introducing additional uncontrolled requests and responses would be risky.
  • Cost - APIs are expensive to build, document, maintain and support.

But that’s just my perspective based on other experiences with APIs. There are more DIY type products that might meet your needs more closely. But then you are going to need to do a lot more by yourself.

I just recently installed this device and like others, was looking to see if any hooks existed for home automation/data analysis/etc. A project comes to mind where someone found MQTT running on the Hue Bridge (v2). This provided me access in real-time to the state of every bulb (subscription). I then use the Hue API to manage the bulbs (no need to publish to control them).

This would be pretty lightweight solution and then you could manage selective consumption through subs via code. Just a thought as I didn’t (quick and dirty search) see any mention of this. So, no worries on documenting an API, just allow us to define an MQ server (e.g., EMQX, Rabbit), security etc. and we can then consume the data in real time. Subscription only as everything else should be defined in the existing configs.