Use template data in lovelace

I am trying to use a data template for a service call in lovelace, I want to switch the device I am sending the command to based on the current activity selected, it doesn’t seem to want to call the service, is something like this possible in lovelace:

- entity: remote.living_room
                tap_action:
                  command:
                    - Exit
                  data_template: >-
                    device: > {% if is_state('sensor.family_room', 'Watch TV')
                    %} 54427908
                name: Exit
                action: call-service
                entity_id: remote.living_room
                icon: 'mdi:exit-to-app'
                type: entity-button
                service: remote.send_command