Skip to content

Commit

Permalink
add input_booleans to control my iMac's volume through HA-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Jan 19, 2020
1 parent 868a4e0 commit fc88446
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 1 deletion.
62 changes: 62 additions & 0 deletions automations/imac-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
- alias: "iMac volume: ensure max 1 input_boolean is on"
trigger:
- platform: state
entity_id: input_boolean.imac_volume_0
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_1
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_2
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_3
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_4
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_5
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_6
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_7
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_8
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_9
from: "off"
to: "on"
- platform: state
entity_id: input_boolean.imac_volume_10
from: "off"
to: "on"
action:
- service: input_boolean.turn_off
data_template:
entity_id: >
{% set x = trigger.entity_id[-1]|int %}
{%- for i in range(11) -%}
{%- if x != i -%}
input_boolean.imac_volume_{{ i }}{%- if not loop.last %},{%- endif %}
{%- endif -%}
{%- endfor -%}
- service: media_player.volume_set
entity_id: media_player.bedroom_speakers
data_template:
volume_level: >
{{ trigger.entity_id[-1]|float / 10 }}
18 changes: 18 additions & 0 deletions includes/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@ iphone_marcella:
- sensor.ssid_iphone_marcella
- sensor.steps_iphone_marcella
- device_tracker.iphone_marcella

ha_menu:
control: hidden
view: no
name: HA Menu Switches
entities:
- switch.bedroom_speakers
- input_boolean.imac_volume_0
- input_boolean.imac_volume_1
- input_boolean.imac_volume_2
- input_boolean.imac_volume_3
- input_boolean.imac_volume_4
- input_boolean.imac_volume_5
- input_boolean.imac_volume_6
- input_boolean.imac_volume_7
- input_boolean.imac_volume_8
- input_boolean.imac_volume_9
- input_boolean.imac_volume_10
24 changes: 24 additions & 0 deletions includes/input_booleans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,27 @@ demo_wake_up_with_spotify:
name: Demo - Start wake up with Spotify
initial: off
icon: mdi:music

# iMac volume (used with https://github.com/andrew-codechimp/ha-menu/)
imac_volume_0:
name: iMac volume 0
imac_volume_1:
name: iMac volume 1
imac_volume_2:
name: iMac volume 2
imac_volume_3:
name: iMac volume 3
imac_volume_4:
name: iMac volume 4
imac_volume_5:
name: iMac volume 5
imac_volume_6:
name: iMac volume 6
imac_volume_7:
name: iMac volume 7
imac_volume_8:
name: iMac volume 8
imac_volume_9:
name: iMac volume 9
imac_volume_10:
name: iMac volume 10
16 changes: 15 additions & 1 deletion includes/switches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
- platform: template
switches:
vacuum_mode:
value_template: "{{ is_state('vacuum.xiaomi_vacuum_cleaner', 'cleaning')}}"
value_template: >
{{ is_state("vacuum.xiaomi_vacuum_cleaner", "cleaning")}}
turn_on:
service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
turn_off:
service: vacuum.return_to_base
entity_id: vacuum.xiaomi_vacuum_cleaner

bedroom_speakers:
friendly_name: Bedroom speakers
value_template: >
{{ is_state("media_player.bedroom_speakers", "on") }}
availability_template: >
{{ not is_state("media_player.bedroom_speakers", "unavailable") }}
turn_on:
service: media_player.turn_on
entity_id: media_player.bedroom_speakers
turn_off:
service: media_player.turn_off
entity_id: media_player.bedroom_speakers

- platform: circadian_lighting
lights_rgb:
- light.toilet
Expand Down
19 changes: 19 additions & 0 deletions lovelace-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,25 @@ views:
show_header_toggle: false
title: Work time
type: entities
- entities:
- icon: mdi:information
name: This is to control the volume using HA-menu on my iMac
type: custom:template-entity-row
- entity: switch.bedroom_speakers
- type: divider
- entity: input_boolean.imac_volume_0
- entity: input_boolean.imac_volume_1
- entity: input_boolean.imac_volume_2
- entity: input_boolean.imac_volume_3
- entity: input_boolean.imac_volume_4
- entity: input_boolean.imac_volume_5
- entity: input_boolean.imac_volume_6
- entity: input_boolean.imac_volume_7
- entity: input_boolean.imac_volume_8
- entity: input_boolean.imac_volume_9
show_header_toggle: false
title: iMac volume
type: entities
icon: mdi:test-tube
path: tests
title: Tests
Expand Down

0 comments on commit fc88446

Please sign in to comment.