Why doesn't visible: "{{ is_state('trigger.to_state.state', 'on') }}" work?

I am having trouble getting the visibility to work for this automation. I checked the other part of the automation by setting visible: True and it works.

automation visibility_entity_group:
  trigger:
    - platform: state
      entity_id: 
       - group.a
       - group.b
       - group.c
  action:
    - service: group.set_visibility
      data_template:
        entity_id: '{{ trigger.entity_id }}'
        visible: "{{ is_state('trigger.to_state.state', 'on') }}"

The example below did it in script . Could it be that visibility can only be set in script like this?

script:
  group_visibility:
    sequence:
      - service: group.set_visibility
        data_template:
          entity_id: '{{ entity_id }}'
          visible: '{{ is_state(cond, visible_state) }}'

https://home-assistant.io/docs/configuration/group_visibility/

I get these errors if I use single quotes, or no quotes or use ==.

2017-11-16 16:33:41 ERROR (MainThread) [homeassistant.components.automation] while scanning a quoted scalar
in “/Users/xxx/.homeassistant/configuration.yaml”, line 4011, column 62
found unexpected end of stream
in “/Users/xxx/.homeassistant/configuration.yaml”, line 4016, column 41
2017-11-16 16:42:21 ERROR (SyncWorker_1) [homeassistant.util.yaml] while parsing a block mapping
in “/Users/xxx/.homeassistant/configuration.yaml”, line 4010, column 9
expected , but found ‘’
in “/Users/xxx/.homeassistant/configuration.yaml”, line 4011, column 56
2017-11-16 16:42:21 ERROR (MainThread) [homeassistant.components.automation] while parsing a block mapping
in “/Users/xxx/.homeassistant/configuration.yaml”, line 4010, column 9
expected , but found ‘’