Sense Energy Monitor

Is there a Smartapp or DTH in the works yet?

I actually got an e-mail today from someone at Sense - he said they’re just about to release a Hue integration (they did that one first because it was one of the easiest) but that they’re planning to do lots more. I’ll ask him about plans with SmartThings.

That said, I got my sense monitor installed a couple days ago, and it just detected its first device (my garage door). I’ll see what I can explore with their API - based on what I’ve done with MyQ, I imagine I could do something pretty similar with Sense devices, and I don’t think it would take more than a few weeks to set up (if I can find the time :slightly_smiling_face: ).

1 Like

Is there anything you would need to know about Sense withing SmartThings other than a device turning on or off? I’ve been able to make that work with a virtual switch and IFTTT. I’ve thought about the API a bit, but the biggest obstacle is keeping the data in sync. I wouldn’t want anything that relies on polling the Sense API for current status.

That would be super interesting… Monitoring this!

It sounds interesting, but could be mainly used for notifications. You could create Pistons that would tell you when devices were on/off (ie. car charging, washer/dryer, iron etc…)

I would love to have this integration so I could show Grid consumption and Solar production tiles on my ActionTiles dashboard that hangs on the wall.

Ah, now ActionTiles integration could be fun. Ok, that may be worth some more API tinkering.

1 Like

After playing with the Sense API a bit, the biggest obstacle seems to be that most of the useful data from Sense only comes through real-time calls that use a websocket, which is not something a SmartApp can handle.

That said, it should be possible to set up a node project that acts a proxy, and that could send data to SmartThings. A few other integrations around here are set up to do that. When I get some time, I’ll see if I can set something up to do that.

I’ve got something in the works now. It will require running a node server on the side, but I think I can make it as easy as possible to set up. I’ve got most of the node piece done, connecting to Sense and pulling real-time data, and I’ve proven I can push data to the hub locally. I think the final result will be pretty sweet. Will post here when I’ve got something good enough to play with.

1 Like

Is this all to create a DTH/smartapp?

What uses are you imagining?

The ability to have identified, but non-IoT electronic devices ability to serve as triggers? e.g. When the dryer turns off, you can have it announced on your DLNA speakers or notification sent to your phone.

Sounds cool!

Getting closer… :slightly_smiling_face:

I’ve got data updates from sense going to device in SmartThings. As things turn on or off, you could then drive whatever other actions you want through routines, webCoRE, or whatever you want. This basically replaces the IFTTT functionality and a lot more.

A few things will be special about this integration:

  • I’m using totally local LAN calls with HubAction - no need for OAuth tokens or any of that mess.0
  • All you’ll need to do is install the node server on a PC or Raspberry Pi, put in the IP address of the ST hub on your network, then start it up. Once you have the SmartApp and DTH code installed in your account, Sense devices will be auto-imported. I’ll add a way to “exclude” Sense devices you don’t care about.
  • The data is being pushed to the hub. No polling or scheduling needed from SmartThings.
2 Likes

Nice work @brbeaird!

I’m curious why you are using “device.switch” for the tiles- wouldn’t “device.presence” be a better UI element since you can’t toggle the device status, only view it?

That’s a good thought - presence might be a good option. My most ideal setup would be a tile on ActionTiles that could combine both the on/off status and the usage amount - since I know there are switches out other now that also measure power use, I thought emulating one of those would be a good start.

I just posted a question in the AT forums asking about the possibility of combining this info into a single tile; if there’s no way to do it I may play around with the presence capability since it really is “read-only” info.

Below are some tiles from my AT panel that show both status and other information like battery level, current temperature readings, etc. I think you just have to define all the capabilities your DTH is utilizing and then make sure that the exposed properties of that capability that you want (e.g. cumulative watts consumed, current watts reading, etc) are defined with the tile UI.

I provided links to three DTH’s used which might help.

Row 1: Contact sensors (some Zigbee, some wired) (DTH)
Row 2: Smoke/CO2 sensors (DTH)
Row 3: Motion detectors (battery % turned off) (DTH)
Row 4: Remote temperature sensors

image

Interesting. The DTH I created just has these capabilities:

Actuator
Power Meter
Switch
Sensor

I have two tiles set up in the DTH - one for switch and one for power.

When I go to add a “thing” in ActionTiles, I see both of those capabilities, but they’re listed as separate boxes to check. I see in my contact sensor tiles where there’s a “Tile footer” option where you can choose whether or not to show the battery indicator. I’m guessing AT has some code in place to recognize contact sensors and just offer the ability to combine those automatically. I’m not sure how to accomplish the same thing with power plus some other “on” indicator.

Looking through your examples, they appear to be doing the same thing I’m doing - including multiple capabilities and adding them as “tiles” within the ST mobile app itself; however, ActionTiles does not seem to directly pull from this info when deciding what tiles actually get multiple pieces of info combined.

My DTH tile:

Relevant code:

definition (name: “Sense Monitor Device”, namespace: “brbeaird”, author: “Brian Beaird”) {
capability “Actuator”
capability “Power Meter”
capability “Switch”
capability “Sensor”
}

simulator { }

tiles (scale: 2){

    standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
        state "off", label: '${currentValue}', action: "switch.on",
              icon: "st.switches.switch.off", backgroundColor: "#ffffff"
        state "on", label: '${currentValue}', action: "switch.off",
              icon: "st.switches.switch.on", backgroundColor: "#00a0dc"
    }

    // value tile (read only)
    valueTile("power", "device.power", decoration: "flat", width: 2, height: 2) {
        state "power", label:'${currentValue} Watts'
    }
    
    main(["switch", "power"])
    details(["switch", "power"])
}

I’m not an expert, but what I see in common with those DTH examples is their usage of the multiAttributeTile() which per the ST documentation:

“Multi-attribute tiles. These tiles can display information about multiple attribute of a device.”

https://docs.smartthings.com/en/latest/device-type-developers-guide/tiles-metadata.html#multi-attribute-tiles

A few more previews of what’s to come…

I’ve got the node proxy pretty much stable. Main thing that’s left is writing some logic to keep devices in sync and offer a way in the SmartApp to exclude devices from Sense you don’t care about. Won’t be long now!

2 Likes

I’m definitely not a developer like you, but do have an RPI to use as a node, but am already using it as a Homebridge relay. Is there a way to run this process in its own “space”, so as to not mix required versions of needed components (like node.js, etc)? Any way to run this on FreeNAS node, which runs FreeBSD I believe?

Your work is awesome, and I can’t believe how quickly you’ve turned this into a working solution!

Thanks for the kind words!

In my experience working with Node, I’ve not run into a lot of situations where things require specific versions of Node itself. Most things tend to be compatible across a pretty big range of versions. Assuming the node version you’re running isn’t super old, I think this should work. If not, I bet we could find a way to tweak things a bit.

If you’re curious enough to give it an early-version tryout, feel free to download the files here: https://github.com/brbeaird/SmartThings_SenseMonitor/tree/master/node_server

Open the config.js file and put in your login information. You can put your Hub IP in there if you want, but obviously without the SmartApp and Device Handler installed, your hub will just receive the data and throw it away.

Run npm install
Run node server.js

You should know pretty quick if it works pulling data back or not.

I did a lot of testing and tweaking over the weekend. I’ve got most of the basic documentation ready, so I should have something ready to go sometime later this week.

This is awesome… It triggered me to finally buy one of these… It will be here tomorrow!
Looking forward to playing with this… Let me know if you need any help with development…

1 Like