Please format code snippets correctly: How to help us help you - or How to ask a good question — looks like you tried but you need three backticks either side of a block of code.
Your switch definition has no way of knowing what state it is in. You need to specify command_state
and perhaps value_template
such that it queries the remote host on the state of the switch.