Need template to use group state to set input_boolean

HI,

I would like to have an input_boolean.motion_sensors_active take the on or off state depending on the state of a group (of motion_sensors).

I have 2 automations for on and off follow the to: state, but can this also be done in 1 automation using a template in the service line?

would this be the way to go?

- alias: Motion sensors active
  id: '1511601479002'
  trigger:
    platform: state
    entity_id: group.motion_sensors
#    to: 'on'
  condition: []
  action:
    service_template: input_boolean.turn_{{trigger.entity_id.state}}
    data:
      entity_id: input_boolean.motion_sensors_active

hope you can have a look?
Marius