If template switch is currently on?

Is there a way to check in value_template if the switch you are working on is currently on?

My case is a chromecast, I want a toggle for when I’m playing a random song from a list, currently i use this:

value_template: "{{ is_state('media_player.hela_huset', 'playing') }}"

It works fairly well, but when I start casting anything else (from spotify on my andorid for example, the toggle turns on. I can’t easily check what media is currently playing so the best would be to some how keep track of the toggler I think, but if I add

value_template: "{{ is_state('media_player.hela_huset', 'playing') and is_state('switch.lonman', 'on' }}", 

the toggler just turns off.

Not really sure what you’re asking. As you note, your value_template can reference states and attributes from anything you can see in HA. You can also use templates in an automation’s conditions to filter out only the triggers you want.