Help with MQTT publish

I have this binary sensor:

- platform: mqtt
  name: Recycling Week
  state_topic: "home-assistant/variable/recycling_week"
  payload_on: "on"
  payload_off: "off"

However I can not get it to change state with this automation:

- id: recycling_week_toggle
  alias: 'Recycling Week Toggle'
  hide_entity: true
  trigger:
  - platform: time
    at: '21:00:00'
  condition:
  - condition: time
    weekday:
     - mon
  action:
    service: mqtt.publish
    data_template:
      payload_template: >
        {% if is_state('binary_sensor.recycling_week.state', 'on') %}
          off
        {% else %}
          on
        {% endif %}
      topic: 'home-assistant/variable/recycling_week'
      retain: true

I have tried using double quotes around the payloads (“on” and “off”) this resulted a payload error.

Found the problem. This:

    {% if is_state('binary_sensor.recycling_week.state', 'on') %}
      off
    {% else %}
      on
    {% endif %}

Should be this:

    {% if is_state('binary_sensor.recycling_week', 'on') %}
      off
    {% else %}
      on
    {% endif %}