GithubHelp home page GithubHelp logo

redphx / ultimate-magic-cube Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 4.0 277 KB

Unlocking the full potential of Mi/Aqara Magic Cube with Home Assistant & Node-RED

home-assistant node-red aqara-cube-sensor aqara

ultimate-magic-cube's Introduction

Ultimate Magic Cube

Unlocking the full potential of Mi/Aqara Magic Cube with Home Assistant & Node-RED.

How it works:

  • Everything is fully customizable.
  • I don't think it's possible to do without Node-RED.
  • Unlike normal usage, you'll need to do an activation gesture first (you don't have to worry about triggering commands by accident when moving the cube around).
  • Each activation gesture enables a set of commands.
  • The cube will be deactivated after X seconds of inactivity (default is 10s). Or you do a slide gesture to deactivate it immediately. All states will be reset.
  • Info of the current action/last action are stored in $flow.cube (this info will be deteled when the cube is deactivated).
{
  "activated_mode": "shake",
  "current_action": {
    "gesture": "flip90",
    "detailed_gesture": "flip_1_2",
    "last_side": 1,
    "current_side": 2
  },
  "last_action": {
    "gesture": "rotate_right",
    "detailed_gesture": "rotate_right",
    "last_side": 1,
    "current_side": 1
  }
}

Setup

Import ultumate-magic-cube.json file to your Node-RED project (it's recommended to create a separate flow/tab for it). Edit your cube's ID in Prepare message node.
I'm using deconz_event event to listen to the cube. If you're using ConBee II or something similar then you can ignore this. Otherwise you'll need to make sure events & gestures pass to Parse event are in this format:

{
  "event": 1002,
  "gesture": 3,
}

With:

  • event: number of the event.
  • gesture: number of the gesture (not string).
    • 1: SHAKE
    • 2: FREE_FALL
    • 3: FLIP_90
    • 4: FLIP_180
    • 5: SLIDE
    • 6: DOUBLE_TAP
    • 7: ROTATE_RIGHT
    • 8: ROTATE_LEFT

How to add/remove activation gestures:

  1. Edit $flow.CUBE_ACTIVATION_GESTURES value in the Setup Gestures node. Supported gestures are available in the Context Data window.

  1. Add/remove these gestures in the Check activated gesture node.

Supported gestures:

  • WAKE_UP: Cube wakes up from sleep. Trigger by the cube itself.
  • SLIDE: Slide. Reserved for deactivating the cube, but you can change/remote if you want.
  • SHAKE: Shake.
  • FREE_FALL: Fall.
  • DOUBLE_TAP: Doble Tap.
  • FLIP: Flip 90/180 degrees. Use this when you don't care about the sides.
  • FLIP_90: Flip 90 degrees.
  • FLIP_180: Flip 180 degrees.
  • ROTATE_LEFT: Turn counter clockwise.
  • ROTATE_RIGHT: Turn clockwise.

Replace X, Y with the side's number (1-6) if you want to be more specific.

  • DOUBLE_TAP_X: Double Tap on side #X.
  • SLIDE_X: Slide the cube when side #X is up.
  • FLIP_X_Y: Flip the cube from side #X to side #Y.

  1. Slide = deactivate cube
  2. Shake = control Spotify
    • Shake: play random playlist
    • Flip 180: play on soundbar
    • Double tap: play/pause
    • Rotate right: next track
    • Rotate left: previous track
  3. Double tap Aqara side (#1) = control lights
    • Shake: randomize colors
    • Flip 90: toggle night light mode of ceiling light
    • Double tap: toggle lights
    • Rotate right: brightness up
    • Rotate left: brightness down
  4. Double tap any other side = control TV/Soundbar
    • Double tap: toggle TV on/off
    • Rotate right: soundbar volume's up
    • Rotate left: soundbar volume's down

ultimate-magic-cube's People

Contributors

redphx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.