Skip to content

Commit

Permalink
use 'input_select's for LSX speaker control in HA-Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Jan 23, 2020
1 parent bfae464 commit 551be90
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 141 deletions.
111 changes: 21 additions & 90 deletions automations/lsx-control.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,9 @@
---
- alias: "LSX: change volume with input_booleans"
- alias: "LSX: change volume with input_select"
trigger:
- platform: state
entity_id: input_boolean.lsx_volume_0
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_1
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_2
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_3
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_4
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_5
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_6
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_7
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_8
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_volume_9
from: "off"
to: "on"
platform: state
entity_id: input_select.lsx_volume
action:
- service: input_boolean.turn_off
data_template:
entity_id: >
{% set x = trigger.entity_id[-1]|int %}
{%- for i in range(10) -%}
{%- if x != i -%}
input_boolean.lsx_volume_{{ i }}{%- if not loop.last %},{%- endif %}
{%- endif -%}
{%- endfor -%}
- service: timer.start
entity_id: timer.block_kef_lsx_volume_sync
- condition: state
Expand All @@ -60,7 +13,7 @@
entity_id: media_player.kef_lsx
data_template:
volume_level: >
{{ trigger.entity_id[-1]|float / 10 }}
{{ trigger.to_state.state|float / 100 }}
- alias: "LSX: sync volume"
trigger:
Expand All @@ -73,47 +26,24 @@
action:
- service: timer.start
entity_id: timer.block_ha_menu_volume_sync
- service: input_boolean.turn_on
- service: input_select.select_option
entity_id: input_select.lsx_volume
data_template:
entity_id: >
{% set volume = (10 * states("sensor.kef_lsx_volume")|float) | round(0) %}
{% if volume == 10 %}{% set volume = 9 %}{% endif %}
input_boolean.lsx_volume_{{ volume }}
option: >
{% set volume = ((100 * states("sensor.kef_lsx_volume")|float) // 5 * 5) | int %}
{% if volume == 100 %}{% set volume = 95 %}{% endif %}
{{ volume }}
- alias: "LSX: set source"
trigger:
- platform: state
entity_id: input_boolean.lsx_opt
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_wifi
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_bluetooth
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.lsx_aux
from: "off"
to: "on"
platform: state
entity_id: input_select.lsx_source
action:
- service: input_boolean.turn_off
data_template:
entity_id: >
{% set x = trigger.entity_id.split("_")[-1] %}
{%- for i in ["opt", "wifi", "bluetooth", "aux"] -%}
{%- if x != i -%}
input_boolean.lsx_{{ i }}{%- if not loop.last %},{%- endif %}
{%- endif -%}
{%- endfor -%}
- service: media_player.select_source
entity_id: media_player.kef_lsx
data_template:
source: >
{% set source = trigger.entity_id.split("_")[-1] %}
{{ source.capitalize() }}
service: media_player.select_source
entity_id: media_player.kef_lsx
data_template:
source: >
{{ trigger.to_state.state }}
- alias: "LSX: sync source"
trigger:
Expand All @@ -125,7 +55,8 @@
{{ trigger.from_state.attributes["source"] != trigger.to_state.attributes["source"]
and trigger.to_state.state != "off" }}
action:
service: input_boolean.turn_on
service: input_select.select_option
entity_id: input_select.lsx_source
data_template:
entity_id: >
input_boolean.lsx_{{ trigger.to_state.attributes["source"].lower() }}
option: >
{{ trigger.to_state.attributes["source"] }}
24 changes: 3 additions & 21 deletions includes/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,13 @@ iphone_marcella:
- sensor.steps_iphone_marcella
- device_tracker.iphone_marcella

ha_menu_lsx_volume:
ha_menu_lsx_control:
control: hidden
view: no
name: HA Menu - LSX volume
entities:
- input_boolean.lsx_volume_0
- input_boolean.lsx_volume_1
- input_boolean.lsx_volume_2
- input_boolean.lsx_volume_3
- input_boolean.lsx_volume_4
- input_boolean.lsx_volume_5
- input_boolean.lsx_volume_6
- input_boolean.lsx_volume_7
- input_boolean.lsx_volume_8
- input_boolean.lsx_volume_9

ha_menu_lsx_source:
control: hidden
view: no
name: HA Menu - LSX source
entities:
- input_boolean.lsx_opt
- input_boolean.lsx_wifi
- input_boolean.lsx_bluetooth
- input_boolean.lsx_aux
- input_select.lsx_volume
- input_select.lsx_source

ha_menu_lsx_power:
control: hidden
Expand Down
30 changes: 0 additions & 30 deletions includes/input_booleans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,3 @@ demo_wake_up_with_spotify:
name: Demo - Start wake up with Spotify
initial: off
icon: mdi:music

# Bedroom speakers control (used with https://github.com/andrew-codechimp/ha-menu/)
lsx_volume_0:
name: LSX volume 0
lsx_volume_1:
name: LSX volume 1
lsx_volume_2:
name: LSX volume 2
lsx_volume_3:
name: LSX volume 3
lsx_volume_4:
name: LSX volume 4
lsx_volume_5:
name: LSX volume 5
lsx_volume_6:
name: LSX volume 6
lsx_volume_7:
name: LSX volume 7
lsx_volume_8:
name: LSX volume 8
lsx_volume_9:
name: LSX volume 9
lsx_opt:
name: LSX on Opt
lsx_wifi:
name: LSX on Wifi
lsx_bluetooth:
name: LSX on Bluetooth
lsx_aux:
name: LSX on Aux
33 changes: 33 additions & 0 deletions includes/input_selects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,36 @@ last_script_bedroom:
- script.white_lights_bedroom
icon: mdi:lightbulb-on


# Bedroom speakers control (used with https://github.com/andrew-codechimp/ha-menu/)
lsx_volume:
name: LSX volume
options:
- 00
- 05
- 10
- 15
- 20
- 25
- 30
- 35
- 40
- 45
- 50
- 55
- 60
- 65
- 70
- 75
- 80
- 85
- 90
- 95

lsx_source:
name: LSX source
options:
- Opt
- Wifi
- Bluetooth
- Aux

0 comments on commit 551be90

Please sign in to comment.