Mi Magic Cube

I was thinking of putting stickers on the sides.
Rotation to control Spotify/Kodi volume based on what side it is on.

Didn’t know there was a double tap event as well.

1 Like

Stickers would be more flexible. Laser etching is kinda permanent :slight_smile:

Laser etch acrylic and attach to the sides? Could have some contrasting colours going on then too?

doing the spinning like clock wise on face
it a bit of hit and miss well more miss than hits
like the stickers idea

The rotation works quite well. The fact is that the cube only sends the event once the rotation has ended, which is a pity.

What I do is I just change the volume with 5% for every rotation event, you usually don’t want a lot more than 5 or 10% change.

Here you have a quite interesting script for AppDaemon working with Xiaomi Cube and deconz

I’m looking for ideas what you control with this thing…

Mine is currently underway, it adds a nice touch to the whole home automation stuff.

I’ve had one for a couple of years now and I still haven’t come up with any use for it. I also searched several times for good examples but haven’t found any ether. :slight_smile:

So if someone has a good idea, I’m all ears. :smiley:

I use to let my 75+ years old parents in law switch off my alarm. Everything from computer to mobile phone is to hard for them to understand. So I just let them shake the cube…:slight_smile:

1 Like

I got one and have set it up to control the lounge lights (shake for on-dimmed-off), and TV/amplifier input (upward side switches to TV / Wii / XBox / Computer / AppleTV / Music. I also have a Harmony Companion, but you have to remember what each button does. Much better with stickers on the sides.

2 Likes

If only I could stream Belgian TV channels to my ChromeCast enabled TV from HomeAssistant - I could then also give it too my parents so they can watch the TV they want when they come babysit.

Kodi has VRT.nu and (if you have Telenet) Yelo plugins, I use those to watch TV, the telenet account does need to have a TV subscription (but you could just as well use your parents’ credentials if they have it and you don’t).

1 Like

Thx but I am a real fan of Plex… also, I’m on Proximus.

How do you know if 1002 is a change from 2 to 1 or it is a rotation with value 1002?

I cannot find a way to separate the many normal events from rotation

Its bas on the event been fired not event been change

Hope that make cents

Yes. I know I need to listen for events. That is the same for all deconz switches.

But the issue is that there is nothing that separates rotation from other events and a rotation can have the same value as a move or turn of the cube.

I have noticed something new.

I deleted my Magic Cube and cleaned manually the core.device_registry and core.entity_registry.

And then restarted HA and repaired the cube.

It then gets recorded as switch_81 and switch_82. 81 is battery sensor also.

Then I restart Home Assistant and the switch_82 autorenames (I did nothing) to Mi Magic Cube. The battery sensor stays as switch_81.

Now turning the cube is switch_82. And rotation are events from mi_magic_cube.

Then I rename the device in Phoscon and all events become the new name and you cannot separate the events again. The problem is that the Cube gets registered as two different switches by default but the minute you rename the cube to something else they merge to one. If the event names has a suffix auto appended it would work.

ok bro

this is my Hassio system

have deConz running inside Hassio

and

hope this help

Yes exactly what I get and the event 1002 can mean flip from face 2 to 1 as well as meaning rotate clockwise 1002 steps. There is no information in the event JSON that says if it is one or the other

I wrote these automation

it just send the event to a MQTT with a bit of English was getting lost

base on

as i dont use appdaemon app

- alias: 'SquareBox Slide'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [1000, 2000, 3000, 4000, 5000, 6000] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data_template:
      payload: >
        Slide-{{ trigger.event.data.event }}
      topic: home/magic_cube
    service: mqtt.publish    

- alias: 'SquareBox double tap'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [1001, 2002, 3003, 4004, 5005, 6006] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data:
      payload: double tap
      topic: home/magic_cube
    service: mqtt.publish 

- alias: 'SquareBox flip180'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [1006, 2005, 3004, 4003, 5002, 6001] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data:
      payload: flip180
      topic: home/magic_cube
    service: mqtt.publish 

- alias: 'SquareBox flip90'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [1002, 1003, 1004, 1005, 2001, 2003, 2004, 2006, 3001, 3002, 3005, 3006, 4001, 4002, 4005, 4006, 5001, 5003, 5004, 5006, 6002, 6003, 6004, 6005] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data_template:
      topic: home/magic_cube
      payload: > 
        flip-{{ trigger.event.data.event }}
    service: mqtt.publish 

- alias: 'SquareBox shake'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [7007] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data_template:
      payload: shake
      topic: home/magic_cube
    service: mqtt.publish 

- alias: 'SquareBox fall'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [7008] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data_template:
      payload: fall
      topic: home/magic_cube
    service: mqtt.publish 

- alias: 'SquareBox wake'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: magic_cube
  condition:
    condition: template
    value_template: >
      {% set valid_events = [7000] %}
      {{ trigger.event.data.event in valid_events }}
  action:   
  - data_template:
      payload: wake
      topic: home/magic_cube
    service: mqtt.publish 

and its sensor

  - platform: mqtt
    name: "magic cube"
    state_topic: "home/magic_cube"
    qos: 1
1 Like

@myle

Your automation will trigger when you rotate the cube clockwise and the rotation happen to match one of your listed values. It may not happen often but it will happen. Normal rotation values easily fall in the 4 digit numbers. There is nothing you do that prevents that