Cube mode


#21

Oh - I should also mention that the Aqara Vibration Sensor uses an accelerometer and earlier versions of the device driver generated ThreeAxis events to store values that are converted into a relative change of XYZ angle used for the driver's open/close sensor functionality.

I could put the ThreeAxis capability back into the driver with a preference setting to enable it, if anyone is interested in trying it out. I imagine you could attach the sensor to the inside face of a homemade cube and use it that way.

In fact, because the sensor detects smaller than 90 degree changes on each axis, it would work inside a shape with more than 6 faces. Just imagine a giant Dodecahedron die so you could "roll a mood!"


#22

Awesome, it absolutely will work then since it is providing emulated 3 axis. I'm excited to get mine.

While the app seems to be working perfectly I'm not satisfied with the V4 MultiSensor itself. If you roll it from flat to a side it always detects the new orientation (as it would be installed and work as a garage door sensor). However, if you roll it from a side to another side without going flat first it often doesn't detect any change in orientation. It's either a problem with the device, device design (I suspect this) or the device handler. I can see that the orientation values freeze in the driver.

Anyway, the Aqara Cube will be a fun toy.


#23

How do you set up your cube in RM? i dont see the options for rotate/shake etc. in button trigger


#24

Those events are just emulated to button events I'm guessing. I will know soon. My cube is scheduled to arrive this week


#25

I received my cube yesterday, neat little device. Awesome job @veeceeoh with the driver!

I tried using the Mood Cube app but couldn't get past the setup screen (errored out). Also, looks like it can only use 7 buttons. Rather than try to figure out someone else's work, I started working on a new app that uses 36 buttons.

I should have a new app ready for testing this afternoon. It'll be a basic turn something on or off based on the button pushed. Working great so far, just need to touch up a few things. :grin:


#26

Thanks, though all credit for the original SmartThings device handler goes to ST Community users @ClassicGOD and @DroidSector. It's my intention to take it to the next level for Habitat users though. Sound like your new app may help with that!

How will your app be different from setting the driver's Cube Mode to "Advanced (36 Buttons)" and using an app like @stephack's Advanced Button Controller, for example?


#27

Don't know, couldn't get Cube Mode to even load the options page so have no idea what it does or looks like. Also don't use Advanced Button Controller so again, don't know what the pros and cons of using that is. Sorry.


#28

That is not good at all, and it's is definitely something I should look into. I'm trying it now in Chrome on Windows 7 and can still see the three settings in the pop-up menu:

Would you mind sending me a PM with more details of what you're seeing when you try to change the Cube Mode setting?


#29

I think that screenshot is from the driver?, that works just fine.

My bad on the wording in my second post. Should have been 'Mood Cube' not 'Cube Mode'

I tried to use the 'Mood Cube' app that is listed above in this thread.
Hit 'add user app' selected Cube Mode, first screen came up and then you have to hit a second button. Page error out and doesn't load. I then deleted the code since it wouldn't even load..


#30

The problem is with the driver I think. I just looked at it but I haven't fixed it yet. The threeAxis attribute needs to be a vector.

https://docs.hubitat.com/index.php?title=Driver_Capability_List#ThreeAxis

The driver puts a String. I tried putting a map there but it's still failing. We need to tweak the event in the driver or nobody will be able to use the threeAxis attribute.

I'll let you know what I find out.


#31

I had to change the driver to this:

	state.remove("threeAxis")
	switch (faceId) {
		case 0: sendEvent([name: "threeAxis", value: "{x:0,y:-1000,z:0}"]); break
		case 1: sendEvent([name: "threeAxis", value: "{x:-1000,y:0,z:0}"]); break
		case 2: sendEvent([name: "threeAxis", value: "{x:0,y:0,z:1000}"]); break
		case 3: sendEvent([name: "threeAxis", value: "{x:1000,y:0,z:0}"]); break
		case 4: sendEvent([name: "threeAxis", value: "{x:0,y:1000,z:0}"]); break
		case 5: sendEvent([name: "threeAxis", value: "{x:0,y:0,z:-1000}"]); break
	}

The state.remove was necessary to reset the data type. It wasn't working at first and I think that fixed it. There may be a better way than this but that fixed it for me.

It still doesn't display like the ST MS though:

ST MS:
image

Aqara Cube:
image

Brace vs bracket. If I put a straight map in it fails to come out in the app or device.currentValue at all. Platform bug maybe, @mike.maxwell? It calls for a vector3 and I don't see that in standard groovy to instantiate.

Mike, can you look at your bit of code in the SmartThings MultiSensor v4 that is sending the threeAxis event? The Samsung source shows they send String but that definitely doesn't work and I don't think you do that based on what data type I get back.


#32

Based on this, and I can't try it where I'm located now, but perhaps this might work:

case 0: sendEvent([name: "threeAxis", value: (["x:0", "y:-1000", "z:0"] as Vector)]); break

or

case 0: sendEvent([name: "threeAxis", value: (["0", "-1000", "0"] as Vector)]); break

or

case 0: sendEvent([name: "threeAxis", value: ([0, -1000, 0] as Vector)]); break


#33

If I try it before you do I'll let you know how it goes.


#34

We build a quick json map for these...
There isn't a vector3 data type internally, it never made much sense anyway.
def value = "[x:${xyzResults.x},y:${xyzResults.y},z:${xyzResults.z}]"


#35

Awesome, that was it.

@veeceeoh, can you change the driver to this without me doing a PR?

switch (faceId) {
	case 0: sendEvent([name: "threeAxis", value: "[x:0,y:-1000,z:0]"]); break
	case 1: sendEvent([name: "threeAxis", value: "[x:-1000,y:0,z:0]"]); break
	case 2: sendEvent([name: "threeAxis", value: "[x:0,y:0,z:1000]"]); break
	case 3: sendEvent([name: "threeAxis", value: "[x:1000,y:0,z:0]"]); break
	case 4: sendEvent([name: "threeAxis", value: "[x:0,y:1000,z:0]"]); break
	case 5: sendEvent([name: "threeAxis", value: "[x:0,y:0,z:-1000]"]); break
}

#36

The Xiaomi/Aqara Cube device driver has been updated here - but note that since I'm at work I'm not able to test it. Thanks for your help!