mirror of
https://github.com/GeorgeSG/sarah.git
synced 2026-09-06 18:08:45 +00:00
Use folder-card. Refactor youtube play scripts
This commit is contained in:
@@ -7,7 +7,7 @@ homeassistant:
|
|||||||
time_zone: Europe/Sofia
|
time_zone: Europe/Sofia
|
||||||
packages: !include_dir_named packages
|
packages: !include_dir_named packages
|
||||||
whitelist_external_dirs:
|
whitelist_external_dirs:
|
||||||
- /config/www/audio/youtube/pds
|
- /config/www/audio/youtube
|
||||||
|
|
||||||
#
|
#
|
||||||
# ─── HOME ASSISTANT COMPONENTS ENABLED ──────────────────────────────────────────
|
# ─── HOME ASSISTANT COMPONENTS ENABLED ──────────────────────────────────────────
|
||||||
|
|||||||
@@ -4,38 +4,47 @@ panel: false
|
|||||||
icon: mdi:youtube
|
icon: mdi:youtube
|
||||||
badges: []
|
badges: []
|
||||||
cards:
|
cards:
|
||||||
- type: entities
|
- type: vertical-stack
|
||||||
style: |
|
|
||||||
ha-icon {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
title: Youtube controls
|
|
||||||
icon: mdi:youtube
|
|
||||||
show_header_toggle: false
|
|
||||||
entities:
|
|
||||||
- entity: input_text.youtube_download_url
|
|
||||||
type: "custom:text-input-row"
|
|
||||||
- entity: input_text.youtube_download_name
|
|
||||||
type: "custom:text-input-row"
|
|
||||||
|
|
||||||
- type: horizontal-stack
|
|
||||||
cards:
|
cards:
|
||||||
- type: entity-button
|
- type: entities
|
||||||
entity: script.youtube_download_selected
|
style: |
|
||||||
name: Download
|
ha-icon {
|
||||||
icon: mdi:download
|
color: red;
|
||||||
icon_height: 48px
|
}
|
||||||
|
title: Youtube controls
|
||||||
|
icon: mdi:youtube
|
||||||
|
show_header_toggle: false
|
||||||
|
entities:
|
||||||
|
- entity: input_text.youtube_download_url
|
||||||
|
type: "custom:text-input-row"
|
||||||
|
- entity: input_text.youtube_download_name
|
||||||
|
type: "custom:text-input-row"
|
||||||
|
|
||||||
|
- type: horizontal-stack
|
||||||
|
cards:
|
||||||
|
- type: entity-button
|
||||||
|
entity: script.youtube_download_selected
|
||||||
|
name: Download
|
||||||
|
icon: mdi:download
|
||||||
|
icon_height: 48px
|
||||||
|
tap_action:
|
||||||
|
action: call-service
|
||||||
|
service: script.youtube_download_selected
|
||||||
|
- type: entity-button
|
||||||
|
entity: script.youtube_download_and_play
|
||||||
|
name: Download & Play
|
||||||
|
icon: mdi:youtube-tv
|
||||||
|
icon_height: 48px
|
||||||
|
tap_action:
|
||||||
|
action: call-service
|
||||||
|
service: script.youtube_download_and_play
|
||||||
|
- type: custom:folder-card
|
||||||
|
entity: sensor.youtube
|
||||||
|
title: Available Youtube
|
||||||
|
icon: "mdi:youtube"
|
||||||
tap_action:
|
tap_action:
|
||||||
action: call-service
|
action: call-service
|
||||||
service: script.youtube_download_selected
|
service: script.youtube_play_file
|
||||||
- type: entity-button
|
|
||||||
entity: script.youtube_download_and_play
|
|
||||||
name: Download & Play
|
|
||||||
icon: mdi:youtube-tv
|
|
||||||
icon_height: 48px
|
|
||||||
tap_action:
|
|
||||||
action: call-service
|
|
||||||
service: script.youtube_download_and_play
|
|
||||||
|
|
||||||
- type: custom:config-template-card
|
- type: custom:config-template-card
|
||||||
entities:
|
entities:
|
||||||
@@ -54,8 +63,10 @@ cards:
|
|||||||
service: script.youtube_play_latest_pds
|
service: script.youtube_play_latest_pds
|
||||||
- type: custom:text-element
|
- type: custom:text-element
|
||||||
text: "${states['sensor.philip_defranco'].state}"
|
text: "${states['sensor.philip_defranco'].state}"
|
||||||
|
- type: custom:folder-card
|
||||||
- type: custom:text-element
|
entity: sensor.pds
|
||||||
text: "Available:"
|
title: Available PDS
|
||||||
- type: custom:text-element
|
icon: "mdi:youtube"
|
||||||
text: "${states['sensor.pds'].attributes.file_list.join('<br />')}"
|
tap_action:
|
||||||
|
action: call-service
|
||||||
|
service: script.youtube_play_file
|
||||||
|
|||||||
@@ -40,3 +40,5 @@
|
|||||||
url: /hacsfiles/travel-time-card/travel-time-card.js
|
url: /hacsfiles/travel-time-card/travel-time-card.js
|
||||||
- type: module
|
- type: module
|
||||||
url: /hacsfiles/weather-card/weather-card.js
|
url: /hacsfiles/weather-card/weather-card.js
|
||||||
|
- type: module
|
||||||
|
url: /hacsfiles/lovelace-folder-card/folder-card.js
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ sensor:
|
|||||||
channel_id: UClFSU9_bUb4Rc6OYfTt5SPw
|
channel_id: UClFSU9_bUb4Rc6OYfTt5SPw
|
||||||
- platform: folder
|
- platform: folder
|
||||||
folder: /config/www/audio/youtube/pds
|
folder: /config/www/audio/youtube/pds
|
||||||
|
- platform: folder
|
||||||
|
folder: /config/www/audio/youtube
|
||||||
|
|
||||||
input_text:
|
input_text:
|
||||||
youtube_download_url:
|
youtube_download_url:
|
||||||
@@ -18,20 +20,25 @@ shell_command:
|
|||||||
youtube_download: python3.7 /config/custom_scripts/youtube_download.py {{ url }} {{ name }} {{ folder }}
|
youtube_download: python3.7 /config/custom_scripts/youtube_download.py {{ url }} {{ name }} {{ folder }}
|
||||||
|
|
||||||
script:
|
script:
|
||||||
youtube_play_latest_pds:
|
youtube_play_file:
|
||||||
alias: Youtube · Play latest PDS
|
alias: Youtube · Play file
|
||||||
sequence:
|
sequence:
|
||||||
- service: script.music_join_sonoses
|
- service: script.music_join_sonoses
|
||||||
- service: media_player.play_media
|
- service: media_player.play_media
|
||||||
data_template:
|
data_template:
|
||||||
entity_id: media_player.master_bedroom
|
entity_id: media_player.master_bedroom
|
||||||
media_content_id: >
|
media_content_id: >
|
||||||
|
{{ states('sensor.sarah_url') }}/local{{ file.split('/config/www') | last }}
|
||||||
{% set last_pds = state_attr('sensor.pds', 'file_list') | sort | last %}
|
|
||||||
{{ states('sensor.sarah_url') }}/local/audio/youtube/pds/{{ last_pds.split('/') | last }}
|
|
||||||
|
|
||||||
media_content_type: "music"
|
media_content_type: "music"
|
||||||
|
|
||||||
|
youtube_play_latest_pds:
|
||||||
|
alias: Youtube · Play latest PDS
|
||||||
|
sequence:
|
||||||
|
- service: script.youtube_play_file
|
||||||
|
data_template:
|
||||||
|
file: "{{ state_attr('sensor.pds', 'file_list') | sort | last }}"
|
||||||
|
|
||||||
|
|
||||||
youtube_download_selected:
|
youtube_download_selected:
|
||||||
alias: Youtube · Download selected video
|
alias: Youtube · Download selected video
|
||||||
sequence:
|
sequence:
|
||||||
|
|||||||
Reference in New Issue
Block a user