summaryrefslogtreecommitdiffstats
path: root/custom
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2023-01-21 01:27:13 +0400
committerSuren A. Chilingaryan <csa@suren.me>2023-01-21 01:27:13 +0400
commit614c8a5f4e3bf26d3af0a91685e00eecb171339b (patch)
tree94a94b63fb3e10a1ec4bf132bd5e3dde4dafae3b /custom
parent2c0c331eb7b7a03152309bbbd4e0fee157e8d86c (diff)
downloadhass-614c8a5f4e3bf26d3af0a91685e00eecb171339b.tar.gz
hass-614c8a5f4e3bf26d3af0a91685e00eecb171339b.tar.bz2
hass-614c8a5f4e3bf26d3af0a91685e00eecb171339b.tar.xz
hass-614c8a5f4e3bf26d3af0a91685e00eecb171339b.zip
Media controls, occupancy tracking, and fixes
Diffstat (limited to 'custom')
-rw-r--r--custom/input_number.yaml5
-rw-r--r--custom/scripts/play-playlist.yaml144
-rw-r--r--custom/scripts/sleep-and-wake.yaml25
3 files changed, 169 insertions, 5 deletions
diff --git a/custom/input_number.yaml b/custom/input_number.yaml
index 0fd1307..2d7ec1c 100644
--- a/custom/input_number.yaml
+++ b/custom/input_number.yaml
@@ -35,3 +35,8 @@
max: 360.0
step: 20.0
initial: 0.0
+ smartpi_playlist:
+ min: 0.0
+ max: 10.0
+ step: 1.0
+ initial: 0.0
diff --git a/custom/scripts/play-playlist.yaml b/custom/scripts/play-playlist.yaml
new file mode 100644
index 0000000..719958c
--- /dev/null
+++ b/custom/scripts/play-playlist.yaml
@@ -0,0 +1,144 @@
+# We can get media_content_id from kodi web interface on port 8080
+
+play_playlist:
+ alias: Play PlayList
+ description: Send one of pre-generated playlists to media player
+ fields:
+ media_player:
+ name: Media Player
+ description: "Media Player"
+ required: true
+ selector:
+ entity:
+ domain: media_player
+ volume:
+ name: Volume
+ description: "Audio Volume: 0 - 1"
+ default: 0.7
+ selector:
+ number:
+ min: 0
+ max: 1
+ step: 0.05
+ playlist:
+ name: Playlist
+ description: "PlayList to play"
+ default: darksoft
+ selector:
+ select:
+ options:
+ - label: DarkSoft Collections
+ value: darksoft
+ - label: Asgard Music
+ value: asgard
+ - label: Asgard Downloads
+ value: downloads
+ - label: Custom
+ value: custom
+ custom:
+ name: Custom
+ description: "Location of custom playlist"
+ default: []
+ selector:
+ media:
+
+ variables:
+ subfolders: [ "Best", "French", "Russian", "Armenian", "Slavic", "Power", "Irish", "Instrumental" ]
+ current: 'input_number.smartpi_playlist'
+ vol: '{{ volume | default(0.7) | float }}'
+ list: '{{ playlist | default("darksoft") }}'
+
+ mode: single
+
+ sequence:
+ - alias: Turn on player
+ service: media_player.turn_on
+ target:
+ entity_id: '{{ media_player }}'
+
+ - service: media_player.volume_set
+ data:
+ volume_level: '{{ vol }}'
+ target:
+ entity_id: '{{ media_player }}'
+
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ list == "darksoft" }}'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ states(current) | float >= (subfolders | length) }}'
+ then:
+ - service: input_number.set_value
+ data:
+ value: 0
+ target:
+ entity_id: '{{ current }}'
+
+ - alias: Iterate Darksoft Playlists
+ service: media_player.play_media
+ target:
+ entity_id:
+ - '{{ media_player }}'
+ data:
+ media_content_type: DIRECTORY
+ enqueue: play
+ media_content_id: '{{ "/home/csa/Music/" + subfolders[states(current) | int] }}'
+
+ - service: input_number.increment
+ target:
+ entity_id: '{{ current }}'
+
+ - conditions:
+ - condition: template
+ value_template: '{{ list == "asgard" }}'
+ sequence:
+ - alias: Play Asgard Music
+ service: media_player.play_media
+ target:
+ entity_id:
+ - '{{ media_player }}'
+ data:
+ media_content_type: DIRECTORY
+ enqueue: play
+ media_content_id: "upnp://4d696e69-444c-164e-9d41-3c7c3f4af5b0/64%240%246%243/"
+
+ - conditions:
+ - condition: template
+ value_template: '{{ list == "download" }}'
+ sequence:
+ - alias: Play Asgard Downloads
+ service: media_player.play_media
+ target:
+ entity_id:
+ - '{{ media_player }}'
+ data:
+ media_content_type: DIRECTORY
+ enqueue: play
+ media_content_id: "upnp://4d696e69-444c-164e-9d41-3c7c3f4af5b0/64%240%241%240/"
+
+ - conditions:
+ - condition: template
+ value_template: '{{ list == "custom" }}'
+ sequence:
+ - alias: Play Asgard Downloads
+ service: media_player.play_media
+ target:
+ entity_id:
+ - '{{ media_player }}'
+ data: '{{ custom }}'
+
+
+ - service: media_player.shuffle_set
+ data:
+ shuffle: true
+ target:
+ entity_id: '{{ media_player }}'
+
+ - service: media_player.repeat_set
+ data:
+ repeat: true
+ target:
+ entity_id: '{{ media_player }}'
diff --git a/custom/scripts/sleep-and-wake.yaml b/custom/scripts/sleep-and-wake.yaml
index b737e8d..a71518a 100644
--- a/custom/scripts/sleep-and-wake.yaml
+++ b/custom/scripts/sleep-and-wake.yaml
@@ -48,7 +48,7 @@ sleep_and_wake:
value_template: '{{ mode == "hibernate" }}'
sequence:
- parallel:
- - service: media_player.media_stop
+ - service: media_player.media_pause
target:
entity_id: media_player.smartpi
# Wait until we fix both sleep and WOL on laptop
@@ -93,16 +93,22 @@ sleep_and_wake:
# - service: switch.turn_off
# target:
# entity_id: switch.plugs_office
+ - service: media_player.media_pause
+ target:
+ entity_id: media_player.smartpi
- service: switch.turn_off
target:
entity_id: switch.smart_power_strip_pro_socket_1
- service: switch.turn_off
target:
entity_id: switch.lights_all
- # Thats a better way to allow some time for leaving
- - service: switch.turn_on
- target:
- entity_id: switch.hall_lights_right
+# Don't do it here, but rather separately when leaving extended home zone
+# - service: switch.turn_on
+# target:
+# entity_id: switch.hall_lights_right
+ - service: input_boolean.turn_on
+ target:
+ entity_id: input_boolean.mode_house_sleep
- conditions:
- condition: template
@@ -114,9 +120,13 @@ sleep_and_wake:
- switch.lights_all
- switch.plugs_manual
- switch.plugs_controlled
+ # Thats a better way to allow some time for leaving
- service: switch.turn_on
target:
entity_id: switch.hall_lights_right
+ - service: input_boolean.turn_on
+ target:
+ entity_id: input_boolean.mode_house_hibernate
- conditions:
- condition: template
@@ -127,3 +137,8 @@ sleep_and_wake:
entity_id:
- switch.plugs_kitchen
- switch.bedroom_bedsidelampsocket
+ - service: input_boolean.turn_off
+ target:
+ entity_id:
+ - input_boolean.mode_house_sleep
+ - input_boolean.mode_house_hibernate