I have two mediacenter computers (NUC with windows7 and mediacenter" with spotify installed. They share the same account and in frontend in hass.io I can select which sorce to control. I have two selections “NUCMEDIACENTER_LIVINGROOM” and “NUCMEDIACENTER_KIDSROOM”. Same names as I have named the computers.
I would like to create an automation that cycles random colors on a lamp in the kids room when they play spotify. But not when playing in the living room.
I have the following automation that I am trying to do just that. I have not come that far to test that the action works yet. I need to somehow make a condition using the “source” parameter.
The condition below is obviusly not working… Any ideas?
- alias: "Media player playing"
trigger:
- platform: state
entity_id: media_player.spotify_vardagsrum
to: 'playing'
from: 'idle'
condition:
- condition: sun
after: sunset
- condition: state
source: "NUCMEDIACENTER_KIDSROOM"
action:
service: homeassistant.turn_on
entity_id: light.light_9
data:
brightness: 100
effect: random
can you please format your code by highlighting it and pressing the </> button. Or you can encapsulate your code in 3 ` (upper left keyboard btn below esc).
to access attributes inside media players, you need to use template_sensors. I don’t believe there is a condition that allows you to use an attribute as a state condition, I could be wrong though. Either way, the template way to do this is:
There are many other ways to do this as well and you will have to single out the media player you don’t want playing. This value template only checks if your current media player is set to NUCMEDIACENTER_KIDSROOM.
Hi again.
The condition does not seem to work. If I remove the condition, the light turns on regardless which mediacenter I use. With the condition nothing works. So it is the condtion that is never true.
Any more ideas? I have renamed the mediaplayer since last post.