From ddd4db1ecca80c1e2ef9e6b71bcd3ba93ef12b82 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sat, 18 Apr 2020 16:31:45 +0300 Subject: [PATCH] Plex on TV automations --- config/lovelace/home_dashboard/09_system.yaml | 17 ++++-- config/packages/modules/media/plex.yaml | 52 ++++++++++++++++++- config/packages/modules/media/tv.yaml | 2 +- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/config/lovelace/home_dashboard/09_system.yaml b/config/lovelace/home_dashboard/09_system.yaml index bf4a341..d933fdc 100644 --- a/config/lovelace/home_dashboard/09_system.yaml +++ b/config/lovelace/home_dashboard/09_system.yaml @@ -7,9 +7,6 @@ cards: title: Automations show_header_toggle: false entities: - - automation.youtube_download_latest_pds - - automation.tv_join_beam_to_sonos_group_when_off - - type: custom:fold-entity-row head: type: custom:dummy-entity-row @@ -59,6 +56,20 @@ cards: - type: divider + - type: custom:fold-entity-row + head: + type: custom:dummy-entity-row + entity: sun.sun + name: Media + icon: mdi:play-box-outline + entities: + - automation.tv_join_beam_to_sonos_group_when_off + - automation.tv_plex_setup_house_for_plex + - automation.tv_plex_restore_house_after_plex + - automation.youtube_download_latest_pds + + - type: divider + - type: custom:fold-entity-row head: type: custom:dummy-entity-row diff --git a/config/packages/modules/media/plex.yaml b/config/packages/modules/media/plex.yaml index c3eaa6d..8d71732 100644 --- a/config/packages/modules/media/plex.yaml +++ b/config/packages/modules/media/plex.yaml @@ -2,8 +2,56 @@ plex: host: !secret plex_host token: !secret plex_token - ssl: true - verify_ssl: false media_player: use_episode_art: true ignore_new_shared_users: false + +automation: + - alias: TV · Plex · Setup house for Plex + trigger: + - platform: state + entity_id: + - media_player.plex_shield_chromecast + - media_player.plex_shield_player + - media_player.plex_lg + to: "playing" + action: + - service: scene.create + data: + scene_id: plex_before_start + snapshot_entities: + - light.living_room_main_lights + - light.pc + - light.tuya_hallway_entrance_lights + - light.tuya_hallway_main_lights + - light.tuya_kitchen_main_lights + - service: light.turn_off + data: + entity_id: + - light.living_room_main_lights + - light.pc + - light.tuya_hallway_entrance_lights + - light.tuya_hallway_main_lights + - light.tuya_kitchen_main_lights + + - alias: TV · Plex · Restore house after Plex + trigger: + - platform: state + entity_id: + - media_player.plex_shield_chromecast + - media_player.plex_shield_player + - media_player.plex_lg + from: "playing" + action: + - service: scene.turn_on + # FIXME: Light colors are not being snapshotted/restored properly. + entity_id: scene.plex_before_start + - delay: 00:00:01 + - condition: state + entity_id: light.pc + state: "on" + # FIXME: There is nothing else to fix the temperature of the PC light + - service: light.turn_on + entity_id: light.pc + data: + color_temp: 250 diff --git a/config/packages/modules/media/tv.yaml b/config/packages/modules/media/tv.yaml index bb25a52..c9e1fe7 100644 --- a/config/packages/modules/media/tv.yaml +++ b/config/packages/modules/media/tv.yaml @@ -25,7 +25,7 @@ script: tv_fireplace: icon: mdi:fireplace - alias: TV · Fireplace + alias: TV · Fireplace sequence: - service: script.tv_prepare_for_playback data: