Ive got a template set to monitor the number of TVs on in the house…for a number of reason…so Ive been using a template as below to strip out the media_player devices that I don’t need to monitor leaving just the TVs in question…
-
platform: template
sensors:
number_tvs_on:
friendly_name: Number of TV On value_template: >- {{ states.media_player | rejectattr('entity_id', 'eq', 'media_player.spotify_jouster') | rejectattr('entity_id', 'eq', 'media_player.studydot') | rejectattr('entity_id', 'eq', 'media_player.studysony') | rejectattr('entity_id', 'eq', 'media_player.studysonyplex') | rejectattr('entity_id', 'eq', 'media_player.gardenroomdot') | rejectattr('entity_id', 'eq', 'media_player.gardenroomdotsonos') | rejectattr('entity_id', 'eq', 'media_player.gardenroomsonos') | rejectattr('entity_id', 'eq', 'media_player.gardenroomsony') | rejectattr('entity_id', 'eq', 'media_player.gardenroomsonyplex') | rejectattr('entity_id', 'eq', 'media_player.appletvk') | rejectattr('entity_id', 'eq', 'media_player.kitchenshow') | rejectattr('entity_id', 'eq', 'media_player.kitchenshowsonos') | rejectattr('entity_id', 'eq', 'media_player.kitchenplaybarsonos') | rejectattr('entity_id', 'eq', 'media_player.loungedot') | rejectattr('entity_id', 'eq', 'media_player.loungedotsonos') | rejectattr('entity_id', 'eq', 'media_player.livingroomsonos') | rejectattr('entity_id', 'eq', 'media_player.madiecho') | rejectattr('entity_id', 'eq', 'media_player.madisonos') | rejectattr('entity_id', 'eq', 'media_player.masterbedroomshow') | rejectattr('entity_id', 'eq', 'media_player.masterbedroomshowsonos') | rejectattr('entity_id', 'eq', 'media_player.masterbedroomsonos') | rejectattr('entity_id', 'eq', 'media_player.ensuitesonos') | rejectattr('entity_id', 'eq', 'media_player.ensuitealexasonos') | rejectattr('entity_id', 'eq', 'media_player.ethandot') | rejectattr('entity_id', 'eq', 'media_player.ethandot') | rejectattr('entity_id', 'eq', 'media_player.ethandotsonos') | rejectattr('entity_id', 'eq', 'media_player.ethansonos') | rejectattr('entity_id', 'eq', 'media_player.outdoor') | rejectattr('entity_id', 'eq', 'media_player.nvidiashield') | rejectattr('entity_id', 'eq', 'media_player.nvidiashieldplex') | selectattr('state', 'eq', 'playing') | list | count + (states.media_player) | selectattr('state', 'eq', 'on') | list | count }}
So its looking for Tvs with the ON and Playing state…
I created a group called media_player.rejectedmediaplayers and added that to the above template and removed everything else and the template returns the group itself as being ON and all other previously ignored media players…is there a way to get around this…or wont this do what I am trying to do
From my end, its just a way to make things simpler going forward and adjust a group as items get added without having to go through and adjust the YAML (which I know wont take that long)
TIA