Hello Everyone,
I am trying to get the state of a media(TV) using Node Red. When I use the debuger to see the attribures that I want to capture. It shows values as follows:
{“topic”:“media_player.master_bedroom_tv”,“payload”:“playing”,“data”:{“entity_id”:“media_player.master_bedroom_tv”,“state”:“playing”,“attributes”:{“volume_level”:0.08,“is_volume_muted”:false,“media_content_type”:“channel”,“source”:“XBox One X”,“source_list”:[“LiveTV”,“Netflix”,“XBox One X”,“YouTube”],“friendly_name”:“Master Bedroom TV”,“entity_picture”:"/api/media_player_proxy/media_player.master_bedroom_tv?token=9fe04c0f235b1453ae8edc43eecee59c10b1f1d294a370a17f51978925ea5d47&cache=65ad96f6df7daf89",“supported_features”:20409},“last_changed”:“2018-03-19T07:14:15.475991+00:00”,“last_updated”:“2018-03-19T07:14:37.506958+00:00”},"_msgid":“b4d64bbb.0064d8”}
so i want to grab the state of data.attributes.source. I wrote a node red function to get me the data and output to 4 different places as seen below.
var newState = msg.data.attributes.source;
if (newState == “Master Bedroom TV”) {
return [ msg, null, null, null ];
}
else if (newState == “XBonx One X”) {
return [ null, msg, null, null ];
}
else if (newState == “youtube”) {
return [ null, null, msg, null ];
}
else if (newState == “Plex”) {
return [ null, null, null, msg ];
}
else { return [ null, null, null, null ];
}
the problem is that data.attributes.source the last attribute “source” shows orange and therefore doesnt grab the state it is in. how can i grab this? thank you in advance.