Modify Multipurpose Sensor Device Handler?

devicetype
communitydevices

(John) #1

I’m pretty new to Smartthings, and am not a programmer or coder, just a “tinkerer”. Anyway, I am using 2 Smartthings Multipurpose Sensors for vibration only, and to keep things clean looking I don’t want to mount the magnet next to it. Ultimately what I would like is to remove the contact sensor option completely, and in my list of devices on my mobile app (iOS) I would like it to show in the list Active/Inactive instead of Open or Close.
I have searched the forum and haven’t found anyone who’s modified the device handler yet, and was just wondering if anyone knew of such a modified device handler. I would also be willing to modify it myself if I knew what I was doing :slight_smile:
Or is this even an option?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

Definitely an option and pretty easy.

It will no longer execute “locally” though.


(John) #3

I’m OK with it not running locally. Neither one are critical.
If it’s pretty easy, would you mind pointing me in the right direction on what to change?


#4

You can go into the IDE, edit your device handler and change which tile to be the main default. You can probably make vibration the main for your device. Look for something like below in the code.

main "humidity"
details([“humidity”, “temperature”, “battery”, “refresh”])


(John) #5

No luck. The only things I could find remotely like that were the tiles and their attributes, but when trying to rearrange them I got errors after trying to create.


#6

Here’s what I did, maybe this will help:

  1. Log into your IDE
  2. Select Device Handlers
  3. In the top right hand, click on Create New Device Handler
  4. From the tabs, click From Template
  5. Scroll down the long list of device handlers until you find SmartSense Multi
  6. Click on it, then scroll all the way back up to the top, you should see some code
  7. Press Command-F (on a Mac ) Ctrl-F (on Windows) for Find
  8. Type in “main” (without the quotes)
  9. You should see the following:
  main(["contact", "acceleration", "temperature"])
  details(["contact", "acceleration", "temperature", "battery"])

Switch contact with acceleration to make that first. Save this out with a different name, then assign this new DH to your SmartSense Multi.

I hope that works, I didn’t really test it but I have done similar to other devices that I have. This will make acceleration the default listing when you view your device in the mobile app. To see the rest, you will need to click through to the main screen.


(John) #7

Thank you so much! That worked perfectly! Now that you’ve shown me how to tweak this, I might just play with it a little bit more :slight_smile:


(Ron Talley) #8

I have one of these “in” my washer…(in zip-lock bag, velcro’d and taped to the side of the drum)<—Don’t laugh, it has been working for months!

However, I only use this to gauge how often the kids are doing laundry. I am not interested in the temperature nor open/close.

The above steps were good to get vibration to be default but, how do I get rid of all of the temperature readings that spam my recent activity feed?

Was reading the HUB update notes on the zigbee OTA firmware updates as well…Hopefully that will fix the constant spamming of active/inactive notifications…

I just want to know when the laundry started and stopped, so maybe only updates every five minutes?

Or an App that does just that, log Laundry Start and Stop times?



#9

I’m interested in something similar: I’m using the sensor with the Mood Cube app, so I’d like to see the xyz axis (or something related, like 1 to 6) rather than the contact status (which doesn’t properly work in my sensor, that’s why I repurposed this as a mood cube “remote”).

Any suggestion? I started tried replacing “contact” with “threeAxis”, but it does not work.


#10

OK, I managed to get the xyz position with this:

	valueTile("threeAxis", "device.threeAxis", width: 2, height: 2) {
		state("threeAxis", label: "$currentValue", backgroundColor: "#e86d13"
		)
	}

…but I’d like to rather show the 1-6 “mood cube way” of interpreting that xyz position. I found the relevant function from the Mood Cube app:

private getOrientation(xyz=null) {
final threshold = 250

def value = xyz ?: cube.currentValue("threeAxis")

def x = Math.abs(value.x) > threshold ? (value.x > 0 ? 1 : -1) : 0
def y = Math.abs(value.y) > threshold ? (value.y > 0 ? 1 : -1) : 0
def z = Math.abs(value.z) > threshold ? (value.z > 0 ? 1 : -1) : 0

def orientation = 0
if (z > 0) {
	if (x == 0 && y == 0) {
		orientation = 1
	}
}
else if (z < 0) {
	if (x == 0 && y == 0) {
		orientation = 2
	}
}
else {
	if (x > 0) {
		if (y == 0) {
			orientation = 3
		}
	}
	else if (x < 0) {
		if (y == 0) {
			orientation = 4
		}
	}
	else {
		if (y > 0) {
			orientation = 5
		}
		else if (y < 0) {
			orientation = 6
		}
	}
}

orientation

}

…but I’m new to ST and don’t know how to actually use it within a tile. Any suggestion?