Cube mode

Just a quick note here to say that I've just released an update to the Xiaomi Cube beta driver that brings back full functionality on all action types (shake, flip, slide, rotate, & knock). All actions generate button X pushed events, with the number of buttons based on the choice of 3 different modes set in the device preferences: 6 buttons, 36 buttons, or 43 buttons.

I'd be very interested to see how well it works in conjunction with @codahq's Mood-Cube app.

2 Likes

Unfortunately as it stands today it wouldn't actually work at all. I didn't do anything but port the ST app over that assumes the device supports three axis aka MultiSensor aka this:

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

So if the events the cube provides are just button clicks you won't even be able to select it as a device in the app. Does the driver also provide ThreeAxis? I could rework the app but there is probably something already better we could start from. In fact, if you are creating button pushed events we should probably just rock the OOB Button Controller for that. It would be king because it can already toggle scenes and other neat things.

By the way, I saw your update even before you posted in this thread and ordered a Xiaomi Cube to play with because of it. You are doing good work over there. Thanks!

*Edit: Actually, now that I'm thinking about it and reading your driver post maybe a large quantity of button press events would have performance issues with Button Controller and Scenes. I dunno. I'll try it out when mine gets here [in probably forever... ordered from aliexpress].

Yes, but only "emulated" in that each of the 3 axis values in each event are either -1000, 0, or 1000 to indicate which face of the cube is facing up, for example 0, 0, -1000 for face 5 (with the Mi logo facing up).

However, per the original author of the SmartThings DTH from which I ported to Hubitat, @ClassicGOD, this should provide support for the Mood Cube app as mentioned in the opening post for his DTH here.

So I still say give it a try!

I highly doubt it will cause any overall hub performance issues, and my experience so far backs that up.

What the driver will cause is a relatively large number of events to be generated, which can lead to slowness when viewing them in the events list page for the device. This is only a concern for a small number of people as best I can tell.

What I was trying to say in my release notes is that I am going to look at any ways that I can reduce the overall number of event entries that the Xiaomi Cube driver generates.

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!"

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.

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

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

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:

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?

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.

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?

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..

1 Like

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.

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.

1 Like

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

1 Like

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

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}]"

1 Like

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
}
1 Like

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!

1 Like