Last active
January 18, 2017 17:04
-
-
Save jjensn/f4f2a29c20c3f4f9e2ca71759d3bb75a to your computer and use it in GitHub Desktop.
Revisions
-
jjensn revised this gist
Jan 18, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ hide_entity: false trigger: - platform: state # this is a smartthings multisensor, connected via MQTT from a SmartThings hub to Home Assistant entity_id: sensor.magic_cube action: - service: light.turn_on -
jjensn created this gist
Jan 18, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ - alias: "Magic Cube" hide_entity: false trigger: - platform: state entity_id: sensor.magic_cube action: - service: light.turn_on entity_id: # any lights you want to change would go here - light.yeelinklightcolor1_miio45091268local - light.yeelinklightcolor1_miio46034208local - light.yeelinklightcolor1_miio48212400local data_template: color_name: >- # there is a limitation with home assistant -- you can't template out RGB colors -- have to use HTML names for now {% set rgb_colors = [ 'white', 'Moccasin', 'PaleVioletRed', 'TOMATO', 'LIGHTSKYBLUE', 'MEDIUMAQUAMARINE' ] %} {% set threeAxis = trigger.to_state.state.split(',')|map('int')|list %} {% set x = 0 if threeAxis[0]|abs < 250 else (1 if threeAxis[0] > 0 else -1) %} {% set y = 0 if threeAxis[1]|abs < 250 else (1 if threeAxis[1] > 0 else -1) %} {% set z = 0 if threeAxis[2]|abs < 250 else (1 if threeAxis[2] > 0 else -1) %} {% if z > 0 %} {% set orientation = 0 if x == 0 and y == 0 %} {% elif z < 0 %} {% set orientation = 1 if x == 0 and y == 0 %} {% else %} {% if x > 0 %} {% set orientation = 2 if y == 0 %} {% elif x < 0 %} {% set orientation = 3 if y == 0 %} {% else %} {% set orientation = 4 if y > 0 else 5 if y < 0 %} {% endif %} {% endif %} {{ rgb_colors[orientation] }}