Improve Plex library sensor description and add automation example (#19740)

This commit is contained in:
jjlawren 2021-10-22 16:48:19 -05:00 committed by GitHub
parent 09de52d6dd
commit 0ef7acfc19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,29 @@ The activity sensor provides a count of users currently watching media from the
The library sensors show a count of items in each library. Depending on the library contents, the sensor will show extra detail in its attributes. For example, a library sensor for TV shows will represent the total number of episodes in the library and its attributes will also report the number of shows and seasons it contains. The library sensors show a count of items in each library. Depending on the library contents, the sensor will show extra detail in its attributes. For example, a library sensor for TV shows will represent the total number of episodes in the library and its attributes will also report the number of shows and seasons it contains.
In addition to the item count, the last added media item (movie, album, or episode) and a timestamp showing when it was added are also provided with each library sensor.
Example automation to use the `last_added_item` attribute on library sensors to notify when new media has been added:
```yaml
alias: Plex - New media added
trigger:
- platform: state
entity_id: sensor.plex_library_movies
id: movie
- platform: state
entity_id: sensor.plex_library_music
id: album
- platform: state
entity_id: sensor.plex_library_tv_shows
id: episode
action:
- service: notify.mobile_app_phone
data:
title: "New {{ trigger.id }} added"
message: "{{ trigger.to_state.attributes.last_added_item }}"
```
<div class='note info'> <div class='note info'>
The library sensors are disabled by default, but can be enabled via the Plex integration page. The library sensors are disabled by default, but can be enabled via the Plex integration page.