I wanted to have a history of what I am listening to when I say “Hey Google, play music”
It might be trivial but I spent a good amount of time getting this right so I’d figured I’d share for the benefit of the next newbie out there.
sensor:
- platform: template
sensors:
bedroom_speaker_song:
value_template: >
{{ states.media_player.bedroom_speaker.attributes.media_title }} by {{ states.media_player.bedroom_speaker.attributes.media_artist }}
friendly_name: Bedroom Speaker Song
icon_template: mdi:music
Some of the links that got me here:
Any help is appreciated!
I’m wanting to log (most for some debugging) what states are when certain actions happen, so after an action … Say a light is powered off I want to log the states of certain things to make sure that what I’m wanting is happening. I am testing this out in a very simple scenario and not getting what I need - See below. The “message” line has the template that I want, but it will not start with that line. Anyone know how I can use a template in a logbook entry?
- alias…
Hello,
I want to trigger an automation everytime the media_title attribute of the media_player (spotify) component changes.
Couldn’t find or figure out any solution. Did anyone already have a solution or a suggestion I can try out?
Thanks in advance.
Been trying to create a template sensor that holds a string based in the input from other sensors:
- platform: template
sensors:
alarm_summary:
friendly_name: 'Alarm summary'
value_template: >
'Alarm {{ states.sensor.alarm_state }} by {{ states.sensor.alarm_changed_by }} the {{ states.sensor.alarm_changed_when }} with a {{ states.sensor.alarm_changed_with }}.'
The expected out put is a string with the following text: Alarm disarmed by Martin the 2019-12-…
7 Likes
Hi, thanks for this.
I would like to use this to keep a record of the tracks we play via our media devices. I have added the sensor and it reflects the track played just fine.
What are you using to display/show the tracks played? Are you showing this in HA?
Thanks again.
Thanks for sharing your result. I’m looking to do similar. Are you using the built in History function in HA to view the history?
OzStone
(Dan)
March 3, 2023, 8:11am
4
This thread was very useful to me, and it led me to create a list of recently played media player songs and when they played
I used this template sensor that I added to configuration.yaml
template:
- sensor:
- name: "Spotify Song & Artist"
state: >
{% if state_attr('media_player.spotify_dan', 'media_title') != none -%}
{{ state_attr('media_player.spotify_dan', 'media_title') }} | {{ state_attr('media_player.spotify_dan', 'media_artist') }}
{%- endif %}
icon: mdi:format-list-bulleted
To display the information I used the Home Feed Card on Github | Forum Thread and these settings on my dashboard
type: custom:home-feed-card
title: Spotify Recently Played
show_empty: false
scrollbars_enabled: false
more_info_on_tap: true
state_color: true
compact_mode: true
entities:
- entity: sensor.spotify_song_artist
include_history: true
max_history: 25
format: time
content_template: '{{state}}'
2 Likes