Inspired by others, sharing what I’ve ended up with so far:
four modes that can be operated from two cubes: Volume mode, Light brightness mode, light warmth mode, temperature mode.
Drop a cube and it says it’s current mode
shake a cube and it moves to the next mode.
I think I might make flip 90 toggle the current entity on/off too.
I haven’t implemented temperature mode yet, which will control my dumb aircon via my xiaomi IR remote
It works, but I don’t feel like having the separate automations/conditions is the most elegant implementation. I tried to do clever stuff with passing variables between automations and scripts, and various other approaches, but I couldn’t get them working.
In my config file:
This is working pretty well, but I got a bit sick of not being able to quickly tell what mode the cube was in (volume, lighting etc) so I changed the change mode action to ‘flip90’ and put some visual indicators on it (the modes are on the four faces that circumnavigate (?) the cube, and the two remaining faces have indicators for which direction to use to change mode (you can’t reverse direction, you have to "go all the way around).
I just used black duck tape and a whiteout pen for the prototype, but I’ll probably have to replace it with something more abrasive resistant.
- alias: Air Shake Changes the Device the Cube Controls
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d00010322b3
action_type: shake_air
action:
- service: input_select.select_next
entity_id: input_select.cube_control_devices
- alias: Play - Pause Media, or Toggle Tradfri Light on Tap Twice
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d00010322b3
action_type: tap_twice
action:
service_template: >
{% if states.input_select.cube_control_devices.state != "light.tradfri_bulb_e27_cws_opal_600lm" -%}
media_player.media_play_pause
{% else %}
light.toggle
{% endif %}
data_template:
entity_id: >
{% if states.input_select.cube_control_devices.state == "light.tradfri_bulb_e27_cws_opal_600lm" -%}
light.tradfri_bulb_e27_cws_opal_600lm
{%-elif states.input_select.cube_control_devices.state == "media_player.hifi_pi" %}
media_player.hifi_pi
{%-else %}
media_player.amp_kodi
{% endif %}
I thought I could avoid using a data_template for the entity_id in the last automation, and that’s why I have the direct device names in the input_select. I haven’t worked out if that’s possible yet.
It works well nonetheless! So I’ll use rotate for Volume on the Media Players, and Brightness on the Light.
Flip90 for next track, Flip180 for previous - and those gestures for changing the colour range on the bulbs.
It’s still not super streamlined, but it’s getting there
Yep. it’s a bit limited, but it’s all pretty manageable. Actually the bigger glaring flaw that I should have foreseen was that I have two cubes and they can’t both stay in sync if you turn one (DOH!). But with one cube, it seems to work well “most of the time”, and if it gets out of sync with where it should be then you can correct it by doing as you’ve suggested - move it very slowly etc.
It looks like the homey xiaomi integration also reports the actual orientation of the cube. This would allow for more use cases. Personally I would like to associate each of the sides with a different scene. I only have to turn it to go into sleep, away, home, tv, etc. mode.
Another option would be to have different times on each of the sides to quickly set an alarm for the next morning. Including a shake gesture to turn the alarm off.
Does someone here use the rotate feature to dimm a hue lamp? I would be interessted in an example config. I already tried it, but did not work. Here is the code I used.
I can confirm when it says entity_id: light.name then that’s the entity id of the light I want to control . I use this input select to control volume or brightness…
ahhh. I missed that ‘cubemode’ selector in your other post and went off on a tangent… That’s a really cool idea to give the cube more use. I’m going to give that a try. Thanks!
EDIT: thinking more about that cubemode idea, I might use the doubletap or something to toggle between two cubemodes for rotate
little bit offtopic, but maybe someone here can help:
my cube entitity changed from XXXXXX to XXXXXX_2 after a reboot or maybe because of the recent update 0.77
I would look in the entity registry to see if the entity is there, but the entity registry is gone in 0.77
How can I change it back to XXXXXX or do I have to change my settings to _2
I think the one idea I came up with is not yet mentioned here. If you add lines like the ones below, you will be able to turn your light off (see complete code in the link above).
The two automations works slightly different from each other. On volume you are increasing the value a fixed amount at each cube event (+0.10 or -0.10). While on brightness control you are increasing it by a variable amount based on how much you did rotate the cube. you could use the same idea from brightness to the volume, but you will have to do some math as the range is not the same (brightness 1-255 and volume 0 to 1.0).
You may try something like this:
volume_level: >
{% set state = (state_attr('media_player.vu',volume_level') + trigger.event.data.action_value|float / 36-%}
{%- if state > 1.0 -%}
{%- set state = 1.0 -%}
{%- elif state < 0 -%}
{%- set state = 0 -%}
{%- endif %}
{{ state }}
I’m not home and don’t remember well what is the range of values the cube reports, but from a automation that i have, something like 18 is like half turn, so you will have to play with the “36” value to adjust the “sensitivity”. Based on these values a half turn should increase/decrease the volume by 0.50 (too much?).